I want to use the DeviceNotifier but it raises an exception when I plug in or unplug the device:
System.OverflowException was unhandled
HResult=-2146233066
Message=Die arithmetische Operation hat einen Überlauf verursacht.
Source=mscorlib
StackTrace:
bei System.IntPtr.ToInt32()
bei LibUsbDotNet.DeviceNotify.WindowsDeviceNotifier.OnDeviceChange(Message& m)
bei LibUsbDotNet.DeviceNotify.Internal.DevNotifyNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
This error only occurs when I set the target framework to 4.5.
When I set the target plattform to x86 it works under .net 4.5 too.
Correction: the error also occures when I set the target framework to 4.0
I have the same problems, unfortunately it occurs on a Windows 8.1 PC, and not on my Windows 7 laptop. Any news?
I noticed the overflow occurs on Win8 or higher because IntPtr has a size of 64bit. Thus casting to 32bits will cause the overflow. Casting to 64 bits will solve this issue.
Quick and dirty fix:
Change function OnDeviceChange in file WindowsDeviceNotifier.cs from
to
and rebuild the dll.