michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

Exception thrown (...): An invalid handle was specified. #262

Closed jelmer3000 closed 2 years ago

jelmer3000 commented 2 years ago

When asking the user to authenticate, I'm running this code every second until succesful authentication:

                try
                {
                    appKey  = await client.RegisterAsync(hueSettings.AppName, hueSettings.DeviceName);
                }
                catch(LinkButtonNotPressedException e)
                {
                    Debug.LogError($"button was not pressed yet.. {e.Message}");
                }

In the editor, this gives a normal exception from my Debug.Log statement. Compiled to UWP however the app crashes with the message: Exception thrown at 0xE3C03498 in HL2HUE.exe: 0xC0000008: An invalid handle was specified.

What could be the reason for this?

jelmer3000 commented 2 years ago

Visual Studio is supposed to "pause" when any exception is thrown. That's why the app stopped when the button was not pressed yet. When running on HL2 without VS attached everything works fine.. I'm not so used to using exceptions in this way I guess.