Question

I have a C# program that uses an external opensource library that I downloaded from the internet, specifically openxml to create excel files. Now I want to run my executable files on computers that do not have this library installed.

I already know that I can have visual studios to make a copy of the library in either the debug or release folder by setting the copy local property to true, and I am doing this.

The problem is that now the executable file can be run on other computers and generate excel files, but the executable file has to be run in the debug or release folder where the library is saved.

When I try to copy the executable file and run it outside of the folder an exception is thrown telling me that the library cannot be found, how do I make it find the library when running the executable outside of the folder?

Thanks,

-Jake

Was it helpful?

Solution

There should be several options that should work.

The problem is that the library is not in the path.

This might help. "http://msdn.microsoft.com/en-us/library/vstudio/6taasyc6%28v=vs.100%29.aspx". You would just need to always have the library in the same location.

You could add the it to the path variable (though this could cause conflicts elsewhere). You could add the folder to the temporary path, i.e. the console whenever it starts up. You could add it to the relative path "Visual Studio: how to set path to dll?"

Hopefully that helps

OTHER TIPS

You could do this in a couple of ways:

  1. ILMerge could merge all the dlls together (if DLL is a C# dll) into a single executable so the libraries are always with you
  2. You could add the DLLs are resources to the project, then on start up spit them out to local directory
  3. Set a directory for reference libraries Using reference libraries (dll) stored in a different folder from the main program?

See also: How can a C++ windows dll be merged into a C# application exe? Embedding unmanaged dll into a managed C# dll Embedding DLLs in a compiled executable Embed C++ Libraries into .Net Libraries

Create a Windows Istaller

If you want to run your software on other machines then why dont you create a MSI ?. pack your external executable file with the MSI. When you install it both your exe and external exe will be extracted to the same location so you wont be having any problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top