Run mono.exe with dll in another folder

I compiled test.cs (which links to a third-party library) using the dmcs for Mac and the following command line program:

 dmcs /out:program.exe test.cs /target:exe /reference:/Users/kevin/path/to/bin/Debug/project.dll 

This compiled without problems (excluding the / reference argument causes problems). This created the executable program.exe in the current directory. When I tried to run it as follows:

 mono program.exe 

I got the following error:

 Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'project, Version=3.4.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 

The only way to solve this problem is to copy the project.dll file to the directory containing the program.exe file. As soon as I copied project.dll to the same directory, the program worked correctly.

Is there an additional argument that I can pass in mono to specify a DLL in another program directory? Or, is there a flag that I can pass to dmcs to force it to compile the DLL directly into a binary file?

+6
source share
1 answer

You can use the research element in app.config to achieve the desired

 <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="bin;bin2\subbin;bin3"/> </assemblyBinding> </runtime> </configuration> 

If you install privatePath in any directory you want. http://msdn.microsoft.com/en-us/library/823z9h8w(v=vs.80).aspx

However, if you do not specify a subdirectory, I would strongly advise on this. If you really don't want to have the assembly in the same directory, consider how to use Uwe Keim or use the GAC.

Link: http://www.mono-project.com/Linker

GAC: http://www.mono-project.com/Assemblies_and_the_GAC

+3
source

All Articles