错误找不到GPIOController

时间:2016-10-14 14:27:46

标签: windows-iot-core-10

希望尽快找到关于这个的指导,我在我的项目中添加了Windows IoT UWT的参考但仍然收到以下错误?

An exception of type 'System.TypeLoadException' occurred in test_led_alljoyn.exe but was not handled in user code

Additional information: Could not find Windows Runtime type 'Windows.Devices.Gpio.GpioController'.

有人在Windows IoT核心上为Raspberry Pi编译应用程序时遇到过这个问题,就我自己的一个示例按钮应用程序工作正常。这是我的代码

    public IAsyncOperation<testlightbulbSwitchResult> SwitchAsync(AllJoynMessageInfo info, bool interfaceMemberOn)
    {
        return (Task.Run(() =>
         {
             SwitchLED(interfaceMemberOn);                 
             return testlightbulbSwitchResult.CreateSuccessResult();
         }).AsAsyncOperation());
    }

    private void SwitchLED (bool state)
    {
        _ledState = state;
        if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Devices.Gpio.GpioController"))
        {
            this.tController = GpioController.GetDefault();
            if (this.tController == null)
            {
                //GpioStatus.Text = "There is no GPIO controller on this device.";
                //return;
                this.tPin = this.tController.OpenPin(5);
                this.tPin.Write(GpioPinValue.High);
                this.tPin.SetDriveMode(GpioPinDriveMode.Output);
            }


            this.tPin.Write(_ledState ? GpioPinValue.Low : GpioPinValue.High);
        }
    }

1 个答案:

答案 0 :(得分:1)

解决。我不得不用.net本地工具链设置构建平台目标编译。