Using AddProfilerResults


I’m using 3.0.10-beta5.

I have 2 projects. One MVC and one WebAPI.

I’m trying to display timing from the WebAPI project within the MVC one using AddProfilerResults.

I’ve looked at the WCF sample and have replicated it in a proof of concept sort of way; serializing a MiniProfiler and including it in the response of the WebAPI project and deserializing it in the MVC project.

The issue I’ve encountered though is that if I call AddProfilerResults on the current profiler when it comes to stopping the profile it crashes because the Profiler property of a Timing class is null - presumably because this isn’t set when it’s deserialised.

As an experiment I tried using reflection to set the Profiler property of all Timing’s in the deserialised profile. I then got results displaying (albeit with negative times etc, but I can work on that after this is sorted).

So, my question is, am I using AddProfilerResults correctly? Should the Profiler property of all the Timings of the MiniProfiler I’m deserializing get restored without me having to use reflection? Is there a better way of doing this?



Instead of using AddProfilerResults (which expects non-null profiler references), have you tried running MiniProfiler.Current.Root.AddChild(deserializedTiming)?


Just had a chance to test your recommendation. Works like a charm; thanks!