C #: specifying location for a Dll reference
In a C # console application, we can add a link to the dll in [Soln Explorer - Links and then add a link to the reqd dll].
In this case, the application expects the dll to be present in the same folder. if not, then the application does not work [Throws an exception].
Is it possible that if the dll is not present in the same folder as in the [exe] application then we have another alternative location \ path from which the program can load the dll reqd and then continue its functionality.
Thanks, Amit
source to share
As pointed out by Fredik , you can install the assembly in the GAC. There is another way to do this. You can copy the assembly to any location (make this location reliable if it is online) and handle the ModuleResolve event of type Assembly. In the callback, you have a chance to resolve the assembly reference.
The second time I would suggest you look at AssemblyResolver . It should definitely resolve any issues that come with resolving assemblies.
source to share
You can add the App.config file to your application and specify the build location:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity
name="MyAssembly"
culture=""
publicKeyToken="8968ee41e78ce97a" />
<codeBase
version="1.0.0.0"
href="file://c:/some_path/myassembly.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
EDIT:
- Maybe you need to set culture = "neutral"
- Make sure the token is correct if the assembly is strongly signed, otherwise publicKeyToken = "null"
source to share