mishrsud / mvc-mini-profiler

Automatically exported from code.google.com/p/mvc-mini-profiler
0 stars 0 forks source link

Null Pointer Exception when calling AddProfilerResults() with de-serialized mini profiler #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When calling AddProfilerResults using a MiniProfiler that has been serialized 
and de-serialized, the Timing items have a null reference on their Profiler 
property. When MiniProfiler.Stop() is called, a null reference is raised.

In my case, the code is run on a remote server without an HttpContext, which is 
why I think you have probably not encountered this issue. Fortunately, it is an 
easy fix, if you would not mind integrating it:

In MiniProfiler.c, the change can be made to the AddProfilerResults() property:

public static void AddProfilerResults(this MiniProfiler profiler, MiniProfiler 
externalProfiler)
{
    if (profiler == null || externalProfiler == null) return;
    if (externalProfiler.Root.Profiler == null)
    {
        externalProfiler.Root.Profiler = profiler;
        SetProfilerForTimings(profiler, externalProfiler.Root.Children);
    }
    profiler.Head.AddChild(externalProfiler.Root);
}

// sets the profiler property of external timings to the current profiler
private static void SetProfilerForTimings(MiniProfiler profiler, List<Timing> 
timings)
{
    if (timings == null) return;
    foreach (var timing in timings)
    {
        timing.Profiler = profiler;
        SetProfilerForTimings(profiler, timing.Children);
    }
}

Also, the setter on Timing.Profile needs to be made public for this to work.

If you could integrate this so that I don't have to merge it each release, I 
would be most appreciative, but if not, it's no drama.

Thanks, Travis

Original issue reported on code.google.com by tsi...@gmail.com on 23 Jun 2011 at 6:01

GoogleCodeExporter commented 8 years ago

Original comment by jarrod.m.dixon on 30 Jun 2011 at 12:09

GoogleCodeExporter commented 8 years ago
what is the state on this, I think I covered this with another change set

Original comment by sam.saff...@gmail.com on 15 Aug 2011 at 12:39

GoogleCodeExporter commented 8 years ago
Having the same issue here. I'm using the 1.77 version (released on 7/27/2011).

Original comment by fernando...@gmail.com on 15 Aug 2011 at 7:58

GoogleCodeExporter commented 8 years ago
can we try on latest source? 

Original comment by sam.saff...@gmail.com on 26 Aug 2011 at 3:10

GoogleCodeExporter commented 8 years ago
This should have been addressed by revision ac9b8521553b.  The profiler is 
still null, but is not used when storing sql results.

Original comment by m...@developer.geek.nz on 28 Aug 2011 at 11:41

GoogleCodeExporter commented 8 years ago
Im marking this as fixed

Original comment by sam.saff...@gmail.com on 14 Feb 2012 at 4:18

GoogleCodeExporter commented 8 years ago
Is it fixed? I have this problem in version 2.1.0.0 from nugget.

Original comment by michelet...@gmail.com on 4 Apr 2013 at 2:16