views:

35

answers:

1

I have a project that I am working on that references a "Common Library (DLL)". In the DevEnv it works fine, however if I build and try to organize my files it doesn't work. Basically if I have things setup like so:

  • C:\Program Files\MyApp\MyApp.exe
  • C:\Program Files\MyApp\Common\WPF Commons.dll
  • C:\Program Files\MyApp\Modules\SomeModule.dll
  • etc

MyApp.exe doesn't work. It tries to look only in the current directory for the DLL files. So how do I set it up in Visual Studio so that when I build the application knows to look for the DLLs in those other folders?

Oh, and I realize that it does work in Dev because all the DLLs are put in the same folder. I don't want to do that for release though :-/

+3  A: 

What you need to do is add a private probing path into the application configuration file. This tells the CLR which directories to look in for extra assemblies.

Sample app.config

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="Common;Modules"/>
      </assemblyBinding>
   </runtime>
</configuration>
JaredPar
Is there an alternate solution aside from copying the MyApp.exe.config file (which can be opened and edited after the fact easily)?
myermian
@myermian you could override the assembly resolve event to do custom resolution. However personally I would go with the app.config one. app.config is *meant* to be editted after the fact to allow for administrators to clean up binding and deployment issues. It's standard practice to use it for probing paths (Visual Studio in fact does this).
JaredPar