07-17-2012 10:39 AM
Hi
I'm trying to call a static method from a .NET assembly provided for a Pololu micro maestro servo controller. Pololu provide the pre-compiled .NET dll as part of their SDK at http://www.pololu.com/docs/0J41.
I am certain that this method can work, as when I build and run the supplied C# project in the SDK, which uses the same dll, it works fine, and my servo controller can be written to.
What I tried was:
And I get the error pictured. I have essentially no idea what this means really, can anyone offer any advice?
Josh
07-17-2012 12:13 PM
Does the .NET class include a constructor? You may need to instantiate an instance of the .NET class, using a constructor, before calling a method on it.
07-17-2012 12:27 PM
For static methods you do not create a constructor, since a static method is tied to the class, not the object, which is what a constructor gives you. So, the steps that Josh is following are the correct ones. As to the issue: You did not indicate what version of .NET was used to create the assemby, or what version of LabVIEW you are using. Is it .NET 4.0? If so, be aware that no shipping version of LabVIEW "officially" supports .NET 4. It may work, it may not. However, a number of people have had problem accessing private assemblies written in .NET 4.
07-17-2012 12:37 PM
Of course, I should have given that information to start with, sorry!
I'm running LabVIEW 2011 SP1 on Windows XP x64 (also on another x86 machine). The readme in the SDK says
All the source code and precompiled binaries here target .NET Framework 3.5, but they should work with later versions of the framework.
So I don't think it's a version problem...
07-17-2012 12:38 PM
Ah, right, missed that key word "static" in the post...
07-17-2012 12:59 PM
Are you running 32-bit or 64-bit LabVIEW? Does the assembly match the bitness?
07-17-2012 03:41 PM
I have 32-bit LabVIEW on both x86 and x64 machines.
The assembly is also 32-bit, so yes, they should match.
07-17-2012 03:46 PM
Although, as an update, I've tried again on the x86 machine and I don't see this error. I'm not sure where that leaves us really. The assembly should still work on x64 as far as I can see, since it functions via Visual Studio C#...
07-18-2012 01:19 PM
Not sure. The only other guess I have is that the assembly was compiled using "Any CPU" rather than x86. Such an assembly would run as 64-bit on a 64-bit platform, but croak when it tries to load a dependent assembly which is 32-bit.