NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
kishd
Posts: 3
0 Kudos

Deploying a C# Application with NI-CAN

Hi,

 

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.

Active Participant
Jeff-P
Posts: 222
0 Kudos

Re: Deploying a C# Application with NI-CAN

Hi kishd,

 

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.aspx

 

I hope that helps!

Member
kishd
Posts: 3
0 Kudos

Re: Deploying a C# Application with NI-CAN

Hi Jeff-P

 

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.

 

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page