Senator George
Senator George

Reputation: 29

Error Couldn't find GPIOController

Hope to find some guidance on this one soon, I've added reference for Windows IoT UWT in my project but still getting the following error ?

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'.

Has anyone come across this issue while compiling applications for Raspberry Pi on Windows IoT core, on it's own one of my sample push button app works fine. Here's my code

    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);
        }
    }

Upvotes: 0

Views: 384

Answers (1)

Senator George
Senator George

Reputation: 29

Solved. I had to set build platform target compile with .net native tool chain.

Upvotes: 1

Related Questions