Profiler serialization issue


I’ve been working on built-in profiler recently and got an issue with the loading method.
The problem happens only when you use custom storage like SqlServerStorage. and try to serialize a loaded profile.

easy way to reproduce:

var profiler = Profiler.Settings.Storage.Load(id);
var json = Profiler.ToJson(profiler);

This throws an unexpected exception.

After investigating with another serializer, it seems that there is a Null reference exception on the ElapsedTicks property.
This property uses data that is not properly initialized.

Can you take a look at this?
Is there any way to create custom resolvers?


Can you provide a small stand-alone project that repro’s this issue, including all configuration used. An easy way to publish a project is on GitHub, or a link to a .zip works too.

Ok, i’ll try to take some time this week to make an example.

Btw, i got my problem solved by building a custom “newtonsoft json” resolver ignoring that property (“ElapsedTicks”).

I have prototyped the standard servicestack profiler to get it work with Selfhost (API profiling), I know you are only supporting mvc, so i won’t bother you with that stuff :slight_smile:

You can find an example here:

You can identify error in SelfhostProfilerHandler → ResultsFullPage method

The serialization issue is not related to the self-hosting implementation,

ok thanks, found an issue with the internal ElapsedTicks property which is not meant to be deserialized that’s now prevented in this commit.

Please let me know if this resolves your issue.

This change is available from v4.0.53 that’s now available on MyGet.

Everything is OK!

Thank you.