Need a .NET 4 version of the drivers?

I have an application where I am building an automated reflection measurement system using a servo and the micro Maestro Controller. I am programming the controls in Visual Studio 2013 and writing in VB. We 3d printed all the necessary hardware, and the system was set up to step through angles and pause while data is collected. Everything was looking great. The Maestro software works, I compiled and ran the demo software (VBCOM2WrapperDemo) and that was fine, and I have written the control routine which steps through various ranges, with various controls on the GUI.

Now the big but…
When I added the library for the optical hardware, I discovered many errors. I could compile and run the demo software for the spectrometer independently, and I could compile and run the servo software, but not in the same project. Being a bit slow on figuring out the error messages, I tried multiple solutions before realizing that the library for the spectrometer is only available for .NET 2.0 or .NET 4.0, and it appears that the Pololu sdk is only compiled for 3.5. Choosing 3.5 as a target for the combined app results in errors for the spectrometer hardware.

It seems to me that I need to get a compatible version of the pololu usbwrapper.dll (and associated required dlls). Is there any way to get such a compiled version with a 4.0 target? I am not an expert in this, so if there is some other easier solution staring at me, please steer me in that direction.


Hello, Mark.

You are right that UsbWrapper.dll was compiled for the .NET 3.5 framework. However, you should be able to use it from other assemblies that are compiled for later versions of the framework. I tested this just now; I was able to compile MaestroAdvancedExample from the Pololu USB SDK with Visual Studio Express 2012 for Windows Desktop. The process of opening the projects in Visual Studio Express 2012 automatically updated them to target the .NET 4 framework, but the UsbWrapper.dll does not get changed and everything still works.

If you change all of your assemblies (except UsbWrapper.dll) and the combined app to .NET 4, what error message do you get?


Thanks David,
I very much appreciate the help.

Perhaps I have left something out of my code. It worked prior to adding the spectrometer calls, but it is possible that I have accidentally modified something during the edits.

I am not getting any compile errors, but at run time, I get an exception thrown of Arithmetic operation resulted in an overflow as a result of the getProductID() call handled in the usbwrapper.dll. I also just noticed a warning that I got (2 related ones actually. I am now using Any CPU in the configuration, but trying x86 causes similar issues.

Warning 1 There was a mismatch between the processor architecture of the project being built “MSIL” and the processor architecture of the reference “NETOmniDriver, Version=, Culture=neutral, PublicKeyToken=5ceb6b3940bb24a4, processorArchitecture=x86”, “AMD64”. This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. ReflectionStage

I am continuing to try to troubleshoot this, and your advice is very welcome.

Thanks again.

I have one more piece of information.

When I open MaestroEasyExampleVB in VS2012, let it convert, then run it, everything appears OK using .NET 3.5 as target. However, if I do nothing other than change the target to NET 4.0, I get the same run time error. Changing back to 3.5 fixes the problem. In both cases, I get the same warning about processor target, but with the 3.5 it runs fine.

I will also try the MaestroAdvancedExample to test that out too. Perhaps something in the configuration is different.

More data…

If I use the MaestroAdvancedExample, it appears to build fine with no errors or warnings under NET 4.0. However, at run time, it never finds the device that is attached.

It runs fine under NET 3.5.

Note that in either case, there was no warning about incompatible platforms (Advanced Example).

It seems to me that this is either a NET version incompatibility which does not show until run time, or perhaps a driver is not happy. I am reinstalling the drivers to make sure they are all OK.

Thanks again!

Hello, Mark.

Thanks to the information you provided, I found that there is a bug in UsbWrapper.dll that causes the “Arithmetic operation resulted in an overflow” exception whenever you try to run it inside a 64-bit process and open a connection to a Maestro.

I will eventually release a new version that fixes this, but in the mean time, please make sure you are running a 32-bit process. You can check that “IntPtr.Size” is equal to 4 to be sure you are running a 32-bit process.

It is not sufficient to just change to the “x86” platform because the “x86” platform in Usc.sln is misconfigured to compile MaestroAdvancedExample for the “Any CPU” target. To run a 32-bit process you should go to the Build tab of the Project Properties page and select “x86” as the Platform Target.