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

Asked

Viewed 68 times

6

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

By default, when . NET executes 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 the GAC %windir%\assembly or %windir%\Microsoft.NET\assembly.

To reduce the size of my installation I had thought to put the assemblies common in a shared directory. There is a way to do this?

Example (structure of a conventional intalation):

Aplicacao1
   Assembly1
   Assembly2
Aplicacao2
   Assembly1
   Assembly3

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

Aplicacao1
  Assembly2
Applicacao2
  Assembly3
lib
  Assembly1

2 answers

6


You can configure 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 manually load.

6

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.