I have a small .NET Framework 4.8 (C#) console app that references a DLL from another application, which in turn depends on a large number of DLLs from the other application. If I copy the dependencies to the folder with the .exe, it works fine:
bin/
my_console_app.exe --> References "referenced.dll"
referenced.dll --> Depends on a.dll, b.dll, ...
a.dll
b.dll
...
But to make things easier to manage, I’d like to put the dependencies in their own directory:
bin/
lib/
a.dll
b.dll
...
my_console_app.exe
referenced.dll
...
After considerable research, I modified the application config file (App.config which Visual Studio copies to “my_console_app.exe.config”) to include a <probing> element like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
</configuration>
However this fails: the console app throws FileNotFoundException on startup with the message “Could not load file or assembly ‘referenced.dll’ or one of its dependencies.”
What have I missed?
Mark Z is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2