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

5

My company has a facility that hits the house of gigabytes. 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. In addition, it also takes into account the assemblies found in GAC %windir%\assembly or %windir%\Microsoft.NET\assembly .

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

Example (structure of a conventional installation):

Aplicacao1
   Assembly1
   Assembly2
Aplicacao2
   Assembly1
   Assembly3

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

Aplicacao1
  Assembly2
Applicacao2
  Assembly3
lib
  Assembly1
    
asked by anonymous 20.02.2017 / 20:02

2 answers

5

You can configure 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 you need to manually upload.

    
20.02.2017 / 20:18
4

As @bigown mentioned, use the probing key 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.

    
20.02.2017 / 20:29