Search code examples
json.netpostsharp

Postsharp and Json.NET


I'm new to PostSharp and trying to do something that that has me vexed, but seems simple:

I'm trying to use Json.Net to serialize and deserialize an instance of MethodInterceptionArgs

Serialization work fine:

string strArgs = JsonConvert.SerializeObject(args);

But I seem to be missing something when deserializing it: What class should I be deserializing it to? MethodInterceptionArgs is abstract, so I don't think that will work.

I could create my own concrete implementation, but that seems ilke it shouldn't be necessary (and I keep getting an error that MethodInterceptionArgs does not contain a constructor that takes zero arguments)



Solution

  • MethodInterceptionArgs is not meant to be serialized. You should copy the relevant pieces of information into another object and serialize it.