Using in .NET 4 application

Oct 27, 2015 at 7:19 AM
I've used this library for a while now, working fine, until I want to include it in a .NET 4.0 application. I now have the application "not responding" and closing down when a device is connected and I call certain methods, like accessing the remote registry.

To locate the cause I've taken the RAPIDeviceUI test application (Form1, without background thread), changed that and the RAPI assembly to target .NET 4.0. When I run this, the application closes without error. By setting breakpoints I can see that it get to the this line:
sb.AppendFormat("Phys Mem:\t{0}K of {1}K\r\n", dev.MemoryStatus.AvailPhysical >> 10, dev.MemoryStatus.TotalPhysical >> 10);
but the application terminates immediately after the first access to "MemoryStatus".


I've also tried the "Form2" version. It doesn't crash/close. Instead it displays this result (even though the device is attached).
Name:   NomadES2MC55592
ID: 60eae810-7a31-2988-fd11-656f39e04189
Platform:   PocketPC
Status: Connected
System.InvalidOperationException: This operation cannot be completed on a disconnected device.
   at System.Devices.RemoteDevice.get_ISession() in D:\prog\.net\ge\TestRapi2\RAPI2\RAPI2\RemoteDevice.cs:line 809
   at System.Devices.RemoteDevice.get_OSVersion() in D:\prog\.net\ge\TestRapi2\RAPI2\RAPI2\RemoteDevice.cs:line 720
   at RAPIDeviceUI.Form2.GetDeviceInfo(RemoteDevice dev) in D:\prog\.net\ge\TestRapi2\RAPI2\RAPIDeviceUI\Form2.cs:line 58
Any suggestions to what is required to get the RAPI2 wrapper working in .NET 4.0 applications would be greatly appreciated.
Oct 27, 2015 at 12:22 PM
After a bit more trial-and-error, I now found that my application runs fine outside Visual Studio 2010, but when run through the debugger it crashes. I still have no idea why, but at least this issues doesn't have to affect the shipped product (only development, which in it self is annoying enough).