How can I indicate the directory where my assemblies should be found?

My company has a facility that hits the Gigabyte home. We have a set of applications in our installation that share the same libraries.

By default, when .NET runs an application it looks for the assemblies in the same directory where the executable is located . In addition, it also takes into account the assemblies found in the GAC %windir%\assembly or %windir%\Microsoft.NET\assembly.

To reduce the size of my installation I had thought to put the common assemblies in a shared directory. Is there a way to do that?

Example (structure of a conventional installation):

Aplicacao1
   Assembly1
   Assembly2
Aplicacao2
   Assembly1
   Assembly3

Example (structure of an installation with assemblies in a shared directory, this is what I wanted to use):

Aplicacao1
  Assembly2
Applicacao2
  Assembly3
lib
  Assembly1
Author: Maniero, 2017-02-20

2 answers

Can set the probing.

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

If this is not enough for you need to load manually.

 6
Author: Maniero, 2020-11-26 15:25:42

As @Maniero mentioned, use the key probing in your web.config or app.config if its value is static.

If it changes programmatically, you can use System.Reflection.Assembly.LoadFrom() to load an assembly directly into the current domain.

 6
Author: OnoSendai, 2019-07-15 11:10:12