How to relocate DLLs RRS feed

  • Question

  • My standalone Windows Forms application requires a few DLLs.  At run time it appears that the DLLs must be in ths same folder as the exe file.  How can I make the program look for DLLs in some other folder, eg .\DLLs or .\bin

    Sunday, September 13, 2009 8:38 AM


All replies

  • If you are talking about .NET assemblies, you can manually load assemblies into your application domain using the AppDomain.Load method. Otherwise, if the assemblies are shared, I recommend to put them into the GAC.
    Geert van Horrik - CatenaLogic
    Visit my blog:

    Looking for a way to deploy your updates to all your clients? Try Updater!
    • Marked as answer by K.Kong Sunday, September 13, 2009 9:16 AM
    Sunday, September 13, 2009 8:57 AM
  • Thanks.  But I can't seem to find an overload that allows the path to be specified.

    Sunday, September 13, 2009 9:46 AM
  • Hi K

    MSDN: How the Runtime Locates Assemblies
    Note   Referenced assemblies outside the application's root directory must have strong names and must either be installed in the global assembly cache or specified using the <codebase> element.

    • Marked as answer by K.Kong Monday, September 14, 2009 2:19 AM
    Sunday, September 13, 2009 11:16 AM
  • Thank you very much.

    It seems what I need is simply setting CurrentDomain.RelativeSearchPath, but unfortunately there's only a Get accessor for this property.

    The writeable property is in AppDomainSetup.PrivateBinPath, but creating a new AppDomainSetup object will only apply to newly created domains.

    It looks like I have to wade into a new area creating new AppDomains.
    Monday, September 14, 2009 1:19 AM
  • Just to let all know that I finally added the following to the app.exe.config file where codeBase specifies the location:



    assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    assemblyIdentity name="yyyyyy" publicKeyToken="fffffffffffff" culture="neutral" />
    codeBase version="" href="subfolder/yyyyyy.dll"/>

    Thursday, September 17, 2009 2:53 AM