dll used by CLR at runtime

隐身守侯 提交于 2021-02-05 08:19:10

问题


I've got a C# application which refers to a .NET DLL.
If this DLL is present both in my application's bin directory and GAC, then which one will be picked up by the CLR at runtime? If GAC has the latest version, would that version be used instead of the one present in bin?

And how do I force the CLR to always use the one in my bin instead of GAC?

According to MSDN:

The CLR checks the global assembly cache, codebases specified in configuration files, and then checks the application's directory and subdirectories.

So, does that mean it looks into GAC first?
Thanks.


回答1:


You force the CLR to not use a copy of an assembly in the GAC by not having it in the GAC. Simple to do by renaming the DLL or by changing its [AssemblyVersion] before referencing it in your project. Skipping this invokes nasty runtime exceptions, otherwise known as DLL Hell.



来源:https://stackoverflow.com/questions/11593394/dll-used-by-clr-at-runtime

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!