.NET Framework Bookmark and Share   
 index > Common Language Runtime > How to relocate DLLs
 

How to relocate DLLs

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

Thanks.
K.Kong
Hi K

MSDN: How the Runtime Locates Assemblies
Observe:
NoteReferenced 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 byK.Kong Monday, September 14, 2009 2:19 AM
  •  
Wole Ogunremi
If you are talking about .NET assemblies, you can manually load assemblies into your application domain using the AppDomain.Loadmethod. Otherwise, if the assemblies are shared, I recommend to put them into the GAC.
Geert van Horrik - CatenaLogic
Visit my blog: http://blog.catenalogic.com

Looking for a way to deploy your updates to all your clients? Try Updater!
  • Marked As Answer byK.Kong Sunday, September 13, 2009 9:16 AM
  •  
Geert van Horrik
If you are talking about .NET assemblies, you can manually load assemblies into your application domain using the AppDomain.Loadmethod. Otherwise, if the assemblies are shared, I recommend to put them into the GAC.
Geert van Horrik - CatenaLogic
Visit my blog: http://blog.catenalogic.com

Looking for a way to deploy your updates to all your clients? Try Updater!
  • Marked As Answer byK.Kong Sunday, September 13, 2009 9:16 AM
  •  
Geert van Horrik
Thanks. But I can't seem to find an overload that allows the path to be specified.

K.Kong
Hi K

MSDN: How the Runtime Locates Assemblies
Observe:
NoteReferenced 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 byK.Kong Monday, September 14, 2009 2:19 AM
  •  
Wole Ogunremi
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.
K.Kong
Just to let all know that I finally added the following to the app.exe.config file where codeBase specifies the location:

<

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

K.Kong

You can use google to search for other answers

Custom Search

More Threads

• How Test if SID is invalid
• Try-catch doesn't catch interop exception
• GetProperties->GetObjectData exception
• send & receive over http without webservices ?
• Prevent Application Termination by Unauthorized Users
• Can't invoke a COM visible method with IntPtr parameter.
• Marshalling a String by reference from C# to unmanaged C++ and back
• Code access Security- when to use and when not to
• Remoting / Binary Serialization compatibility between 1.1 and 2.0 versions of the Framework
• Could not load file or assembly xxx or one of its dependencies.Strong name validation failed