Crash in .NET with new Nano


I’m getting an inconsistent crash inside HidSharp.

The method in HidSharp is below:

public unsafe override void GetFeature(byte[] buffer, int offset, int count)
   Throw.If.OutOfRange(buffer, offset, count);
		 fixed (byte* ptr = buffer)
			if (!NativeMethods.HidD_GetFeature(_handle, ptr + offset, count))
			{ throw new IOException("GetFeature failed.", new Win32Exception()); }  <------------ exception here

Here is my call stack at the time:

HidSharp.dll!HidSharp.Platform.Windows.WinHidStream.GetFeature(byte[] buffer, int offset, int count) Line 78
BlinkStickDotNet.dll!BlinkStickDotNet.BlinkStick.GetColors(out byte[] colorData) Line 790            
BlinkStickDotNet.dll!BlinkStickDotNet.BlinkStick.GetColor(byte index, out byte r, out byte g, out byte b) Line 824
BlinkStickDotNet.dll!BlinkStickDotNet.BlinkStick.Morph(byte channel, byte index, byte r, byte g, byte b, int duration, int steps) Line 1016     
BlinkStickDotNet.dll!BlinkStickDotNet.BlinkStick.Pulse(byte channel, byte index, byte r, byte g, byte b, int repeats, int duration, int steps) Line 1118C#
BlinkStickDotNet.dll!BlinkStickDotNet.BlinkStick.Pulse(byte channel, byte index, BlinkStickDotNet.RgbColor color, int repeats, int duration, int steps) Line 1137      
BlinkStickDotNet.dll!BlinkStickDotNet.BlinkStick.Pulse(byte channel, byte index, string color, int repeats, int duration, int steps) Line 1150     
CheckForMeetingReminders.exe!CheckForMeetingReminders.Program.AnimationForEmails() Line 270

And here is the code that I called that caused the issue:

Line 270: device.Pulse(0,1,"green");

Am I doing something wrong? Yes I’ve opened the device, and this is basically based on code in the .NET Examples.

Yes this is a Nano, and I was trying to access the second LED. If I use


I haven’t seen the issue.


Hey Aric,

please give us a few more lines of your code.
An error regarding “GetFeature” is often a missing delay between the commands.

For example do a


before your pulse


That would explain it. I was trying to blink the front LED just before my Pulse call to the back LED. I will make sure to add a delay between the calls. Thanks.

BTW is that documented somewhere? I kind of feel like I’m missing some info that would avoid these newby questions.



Well, it is not really documented, so it isn´t your fault. In some wiki examples there is a thread.sleep and here in the forums there are often posts regarding this.