Link to DLL without copying C #
When we create a new C # project and reference the dll, the dll is copied to the project output directory when the project is compiled.
Is there a way to reference the DLL files, rather than copy them into the project's output directory, and have an executable with them on startup (something like Assemblies
, if I'm not mistaken)?
I tried to access the properties of the referenced dll and changed Copy Local
to False
, but that didn't work (possibly because this dll depends on other DLLs located in the dll directory).
Is there a way to do this?
source to share
You can actually copy the brackets in the GAC , but this is not always a perfect solution.
You have to remember that every assembly copied to the GAC must be strong with a name . If your projects use some NuGet packages, it would be a challenge to install all of these packages in the GAC. I believe this is not the purpose of using NuGet.
Another option would be to load your DLLs from different default directories bin
using a tag <codeBase>
in your config:
<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>
but as far as I remember it is possible at runtime.
EDIT: Since your problem is that you need to refer the SDK which is in development, I think neither the GAC nor codeBase
will work. One thing is the version issue (you have to reference a specific SDK version) and the second is that you should always recompile your tool after a new SDK is released because some metadata is stored in your assembly, which may be outdated with the new version SDK.
source to share