How to identify if a GAC assembly is loading

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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.

Method 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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x