I'm trying to reference a .NET dll in a different folder for my program ex: Executable.exe --> bins --> ref.dll
I'm using Visual Studio 2019 to edit my project
I'm trying to reference a .NET dll in a different folder for my program ex: Executable.exe --> bins --> ref.dll
I'm using Visual Studio 2019 to edit my project
Assuming this is a .NET Framework application, you can accomplish this by setting the <probing />
element (reference) in your application or machine configuration file. So, for your example, if you wanted to add the /bins
folder to your assembly search path, you'd use:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;bins"/>
</assemblyBinding>
</runtime>
</configuration>
Obviously, this will only work if you know the locations upfront. If you need to dynamically configure the search path at runtime, you'll need to use something like AppDomain.AssemblyResolve
event. That is a bit more involved, but provides more flexibility if you need it.