views:

59

answers:

3

Hi All, I have a C# project that I have created in Visual Studio Express 2010. This program uses a 3rd party C# class that relies on/calls a C++ dll. I just copied the filename.dll into the bin/debug and bin/release folders of the project folder, and the application ran fine.

I am under the assumption that I can copy the release executable for the project to another computer and run it as long as the filename.dll is in the same directory as the executable. However, trying this on another computer with correct frameworks installed, etc. the program crashes with a system.dllnotfoundexception.

Strangely, my friend reports that the program runs on his computer with Visual Studio installed, but not the one without, though I have not actually seen this.

What could be causing this? And how can I get the release executable to run on another machine?

Thanks for any replies! -Chase

+4  A: 

Make sure you have the Visual C++ runtime installed (VS2005,VS2008,VS2010).

leppie
A: 

The easiest (albeit maybe not the "best") solution to this problem is adding a Setup project to your solution. A setup project will help you find any dependencies, and make them available during install.

The steps you need to take are the following:

  1. Add a Setup project to your solution (found in Add project.../Setup templates)
  2. Right-click the project, choose "Add/Project output..." and add the startup project of your program.
  3. Right-click the project and choose "View/Custom actions".
  4. Right-click the root node, select "Add Custom Action..." and from "Application Folder" add "Primary output from [your project name here]".

Now when you compile, an .msi installer is created. Run this installer on the other computer, and your program will be installed and runnable. To uninstall, run the installer again, or remove the program from "Add/Remove programs" under Control panel.

Tomas Lycken
+1  A: 

If your c++ dll is build by visual studio it may depends on the CRT, two things to check here :

  • If it depends on the release or debug CRT. Microsoft don't give you the right to distribute the debug version except for debugging purposes so it could be a problem.
  • Witch version it depends on
    • The last version from vs2010 could be copied in the same directory as the executable (msvcp100.dll for c++ msvcr100.dll for C)
    • Previous versions needed to be installed as side-by-side assemblies so running their setup was mandatory (Some versions like the VS2005 one are included in framework install but others like the VS2005 SP1 one need to be installed separately)

In any case the best way to debug such problems is to install Dependency Walker (free) on the computer having problems and let it tell you what dll is missing.

VirtualBlackFox