How to identify if a GAC assembly is loading

断了今生、忘了曾经 提交于 2019-12-20 04:23:35

问题


I have installed Visual Studio 2011 beta, and have found that a website I was working on has since stopped working. It has been suggested that there is an MVC or Razor assembly from the GAC which is loading and taking over. How would I check this?


回答1:


Run the application in Debug mode and watch the Output window in Visual Studio. It will list every assembly as it is loaded, you will recognize GAC assemblies easily by its full file path.




回答2:


Just of interest let's do it i runtime. The idea is - check out Assembly.GlobalAssemblyCache property of all loaded MVC assemblies.

Put the following code snippet somewhere in Page_Load() and see in a file whether specific assembly was loaded from GAC:

using System.Linq;
var items = AppDomain.CurrentDomain
                     .GetAssemblies()
                     .Where(a => a.FullName.Contains("MVC"))
                     .Select(a => String.Format(
                                         CultureInfo.InvariantCulture,
                                         "[{0}] {1}",
                                         a.GlobalAssemblyCache,
                                         a.FullName));

File.WriteAllLines("c:\\assembliesdump.txt", items .ToArray());   

Output will be like shown below (log4net filter as example):

[False] log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821



来源:https://stackoverflow.com/questions/9571658/how-to-identify-if-a-gac-assembly-is-loading

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