When compiling a C# project which has external references, the referenced dlls are being copied to the project's output path (next to the exe).
When running the application, it expects to find the dlls next to the exe.
I'm looking for a way to spread my dll files into different directories Dlls for starters). And have the exe look for the dll files in those directories.
Example:
Let's say we have an application called "App" located under C:\App\App.exe
, and also it uses a dll file called "App.dll" which is currently also located under C:\App
.
I wish to create a new directory called C:\App\Dlls
and move the App.dll file to there, while making sure that the App.exe file will know to look for the dll in the new location.
I've searched the internet and found the probing solution. Here's my code (edited "App.config" file):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas=microsoft-com:asm.v1">
<probing privatePath="Dlls" />
</assemblyBinding>
</runtime>
</configuration>
I compiled my application, created the Dlls directory and moved all the dll files to that directory, but the application crashes.
What am I missing?