How to stop certain assemblies from being loaded from the GAC?
I have some third party assemblies installed in the GAC. I am developing an ASP.NET which uses some of these assemblies. In the development machine if an assembly is not in the bin folder it gets loaded from the GAC. This situation masks the situation if an assembly is missing in the bin folder because no errors are reported. However when the app is deployed on a shared host, if an assembly is missing from the bin folder, the app errors.
Is there a way to force the app not to load certain assemblies from the GAC and report an error if its missing in the bin folder in the development machine?
You can't, as far as I know.
The answer to questions of the kind "Doctor, it hurts when I do this" is usually "Then don't do that".
In other words: Don't install the third party assemblies in the GAC on your development machine.
For reason, I think you already know what the solution is. You should simply put these assemblies in the bin folder of your web app and then specify the assembly name in the required section of the web.config
file. For example, if it is a server control that you want to register in all pages you add it in the pages
section...
<pages styleSheetTheme="DefaultTheme" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
</controls>
</pages>
if it is a custom module, you should specify in the modules
section...
<httpModules>
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
</httpModules>
You should always strive to set a development environment as close as possible to a production environment, which means third-party assemblies which are distributed with the .NET Framework should go in the bin...I mean, the bin folder, not the rubbish bin ;)
NO, You cannot!. This is a fixed behavior by the CLR's Fusion engine.
The Fusion engine (responsible party for loading assemblies in .Net) ALWAYS walks it's steps (temp/download/gac/base path/probe paths) and you cannot prevent/change this.
if you have an assembly in two places, the one which is located first in the list mentioned above is loaded (can be very confusing with different versions).
链接地址: http://www.djcxy.com/p/44440.html上一篇: 在Vista客户端上安装后SQL紧凑问题
下一篇: 如何阻止从GAC加载某些程序集?