Nathan Ridley
Nathan Ridley

Reputation: 34396

How do I give my .net app secondary locations to look for dependent assemblies?

I'm sure this was asked somewhere in another question, but the wording used there obviously is not generic enough to find easily.

How do I tell my windows forms application about secondary locations that it can find assemblies that it may need at run time? I'm not talking about using reflection to discover plugins, but rather dependencies that have been compiled into the assembly but may be located in a subdirectory rather than side-by-side with the calling assembly.

Upvotes: 2

Views: 75

Answers (1)

Anton Gogolev
Anton Gogolev

Reputation: 115731

You can do this through application config file: assemblyBinding element, more precisely - probing:

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

This will force runtime to look for assemblies in bin, bin2, bin2\subbin and bin3 directories, all of which are subdirectories of the application's base directory.

Upvotes: 9

Related Questions