05-14-2012 05:07 PM
I've been working lately on updating some of the software at work. Almost all of it is written in C++. Now, people want to move towards C#. For NI CAN we have a (C++) wrapper that makes a .dll (canInterface.dll) which has been used successfully on a multitude of application deployments.
Moving to C# I have something that works with the C++ implemented wrapper. The Caveat here is that it only works on computers with Visual Studio Installed. I can't be installing visual studio on every machine that needs to run this little program.
When installing the program on other computers it installs successfully, however when loading up the program I have a "System.io.filenotfound" exception. The exception mentions explicitly that "canInterface.dll or one of its dependencies could not be loaded." I know the DLL itself is installed and referenced because if I delete it, windows gives me a different error.
I'm using the NI CAN USB 8473, I have the most up to date drivers (2.7.2?) I've installed Microsoft .NET 4.0 on both machines. I have absolutely no idea what dependency is not found.
Has anyone else ran into this problem? Did you find a solution? Failing that, how much is involved in re-writing a wrapper for NI CAN in C#? I found one from 2009 on this forum already, but I can't even get that to compile. Let alone run on another machine.
Thanks for your time.
05-15-2012 07:23 PM
I have been looking into the exception you are seeing and I didn't find a lot of information. However if you are trying to use your C++ wrapper in C# you will run into some problems since C# is .NET and C++ is not so you will need an interop wrapper to move between the two, which is a non-trivial task. There is more information on interop wrappers here - http://msdn.microsoft.com/en-us/library/ms173184.a
I hope that helps!
05-17-2012 07:18 AM
I already have a wrapper from C++ to C# that works. I think the C# is using system.InteropServices as well.
I know that has to be working because when I run programs in debug mode I can use that wrapper fine. The problem arises from compiling release mode and installing on another machine. I've been plugging away at this and I think it might just be a mistake in how it builds the project. It currently looks like it can't find msvcr100D.dll. Which it won't find because its a debugging DLL.
Once Im sure I have this working I'll post back with how I fixed it.