Click here to Skip to main content
15,893,487 members

Response to: DLL must exist in same folder as executible

Revision 2
Yes, you may need some library assemblies in a different folder. For example, you need it if you have some different applications using shared libraries and you don't want to mix them together or put anything in GAC. Here is one of the methods based on application config file:

Let's assume the main executable module of your entry assembly is "myApplication.exe", then you can create the file "myApplication.exe.config" with something like:
HTML
<configuration>
	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<probing privatePath="..\MyLibraries\MySharedAssemblies"/> <!-- or whatever directory you need -->
		</assemblyBinding>
	</runtime>
</configuration>

If you do this, you can place your shared assemblies in the directory "..\MyLibraries\MySharedAssemblies" (can be anything else). In this example, the path is relative to the location of the main executable module of your entry assembly and config file, but it could be anything, including absolute path, but relative is more manageable.

There are other methods of the resolution of assembly location; I prefer this one.

—SA
Posted 5-Nov-12 11:55am by Sergey Alexandrovich Kryukov.
Tags: