Reputation: 361
I've got an executeable file, which I run for example from C:. The executable references some DLLs from another directory, let's say C:\MyDLLs. The problem is, that these referenced DLLs again depend on other DLLs, which are stored in another directory. Can I tell Visual Studio where to look for these missing DLLs? Thanks a lot!
Upvotes: 2
Views: 2330
Reputation: 28701
You can reference assemblies outside of your app's assembly loading rules by setting these values in configuration. Here's a sample configuration file from this Microsoft KB article:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyAssembly2" culture="neutral" publicKeyToken="307041694a995978"/>
<codeBase version="1.0.1524.23149" href="FILE://C:/Myassemblies/MyAssembly2.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
You use the <codeBase>
element to tell your app where to look.
You have to make the assembly strong named (use the sn.exe tool) for this to work.
It's also useful to understand how the runtime resolves assembly references and maybe you can take advantage of that instead of going through all the hoops to use <codeBase>
.
Upvotes: 3
Reputation: 5043
I've had this issue before and I created a post build script that copies all the needed DLLs into my executable's directory.
Something like: copy "$(ProjectDir)Resources\DLLs\yourDLL.dll" "$(TargetDir)yourDLL.dll"
Upvotes: 1