Question

We're trying to get Glimpse up and running in our environment but coming across a strange problem.

We've installed Glimpse.Core, Glimpse.AspNet, and Glimpse.Mvc3.dll and when we configure web.config to enable Glimpse everything works fine until the Application Pool recycles. Once the AppPool recycles, it's as if the site 'forgets' about Glimpse.Mvc3.dll and the Mvc3 tabs (Execution, Model, Metadata) disappear.

Here are the steps (for us) to reproduce:

  1. Modify web.config to include Glimpse configuration
  2. All tabs will show including Execution, Metadata, and Model Binding
  3. Perform an Application Pool recycle
  4. The MVC3 Glimpse tabs will no longer show (but the others will)

Prior to the AppPool recycle, Glimpse.axd shows the following Registered Tabs:

  • Glimpse.AspNet (1.3.1)
    • Configuration - Glimpse.AspNet.Tab.Configuration
    • Environment - Glimpse.AspNet.Tab.Environment
    • Request - Glimpse.AspNet.Tab.Request
    • Routes - Glimpse.AspNet.Tab.Routes
    • Server - Glimpse.AspNet.Tab.Server
    • Session - Glimpse.AspNet.Tab.Session
  • Glimpse (1.5.0)
    • Timeline - Glimpse.Core.Tab.Timeline
    • Trace - Glimpse.Core.Tab.Trace
  • Glimpse.Mvc3 (1.3.2)
    • Execution - Glimpse.Mvc.Tab.Execution
    • Metadata - Glimpse.Mvc.Tab.Metadata
    • Model Binding - Glimpse.Mvc.Tab.ModelBinding
    • Views - Glimpse.Mvc.Tab.Views

And post AppPool recycle, Glimpse.axd shows the following Registered Tabs:

  • Glimpse.AspNet (1.3.1)
    • Configuration - Glimpse.AspNet.Tab.Configuration
    • Environment - Glimpse.AspNet.Tab.Environment
    • Request - Glimpse.AspNet.Tab.Request
    • Routes - Glimpse.AspNet.Tab.Routes
    • Server - Glimpse.AspNet.Tab.Server
    • Session - Glimpse.AspNet.Tab.Session
  • Glimpse (1.5.0)
    • Timeline - Glimpse.Core.Tab.Timeline
    • Trace - Glimpse.Core.Tab.Trace

It's as if the site is 'forgetting' about Glimpse.Mvc3.dll as part of the AppPool recycle.

Any ideas/suggestions greatly appreciated.

Was it helpful?

Solution

The reason seems to be ASP.Net and the way it loads assemblies from your application directory for the first time and after a recycle. On first start, the assemblies are loaded from your application's bin directory and after a recycle (or even an IIS restart) it loads the assemblies from the Temporary ASP.NET Files directory. And depending on the situation more or less assemblies are loaded.

You can see this for yourself by adding the following lines to your Application_Start method in your Global.asax

protected void Application_Start()
{
    Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
    bool glimpseMvc3AssemblyLoaded = loadedAssemblies.Any(a => a.FullName.Contains("Glimpse.Mvc3"));
    File.AppendAllText(
        "C:\\temp\\output.txt",
        string.Format(
            "{0}{1} assemblies loaded and Glimpse.Mvc3 is{2} one of them",
            Environment.NewLine,
            loadedAssemblies.Length,
            glimpseMvc3AssemblyLoaded ? string.Empty : " not"));
}

If you run that then you will see the following entries in your output.txt file (although numbers may differ)

On first initial start:

60 assemblies loaded and Glimpse.Mvc3 is one of them

After recycles

30 assemblies loaded and Glimpse.Mvc3 is not one of them

30 assemblies loaded and Glimpse.Mvc3 is not one of them

After removing the corresponding directory inside the Temporary ASP.NET Files directory

70 assemblies loaded and Glimpse.Mvc3 is one of them

How does this correlate with Glimpse. Well Glimpse makes a call to AppDomain.Current.GetAssemblies() after which it will look for types that implement ITab, but if the Glimpse.Mvc3 assembly isn't returned then tabs defined inside of it won't be discovered and hence not shown.

Does this solve your issue? I'm afraid not, but I think it is better to continue this discussion on the glimpse issue tracker, as a matter of fact I already found a similar issue over there, but I'm not sure if it is yours.

Update There will be a fix in one of the upcoming releases of Glimpse, but in the meanwhile there is a solution/workaround, as mentioned in one of the comments on the Glimpse issue.

Simply add the following statement to the Global.asax Application_Start method

BuildManager.GetReferencedAssemblies()

and you're good to go

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top