1

Closed

Serializing/Deserializing .NET exceptions

description

I trying to serialize a .NET exception but I'm only able to deserialize it as the base type System.Exception and not as its derived type System.InvalidOperationException. Even if I call DeserializeObject<System.InvalidOperationException>.
 
Is there something I'm missing?
 
My serialized object looks like this:
 
{"ClassName":"System.InvalidOperationException","Message":"Outter exception...","Data":null,"InnerException":{"ClassName":"System.Exception","Message":"Inner exception...","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":null,"RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":null,"HResult":-2146233088,"Source":null,"WatsonBuckets":null},"HelpURL":null,"StackTraceString":" at MyApp.LoginBiz.Login() in C:\MyApp\LoginBiz.cs:line 44\r\n at MyApp.LoginSvc.Login() in C:\MyApp\LoginSvc.cs:line 71\r\n at SyncInvokeLogin(Object , Object[] , Object[] )\r\n at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)\r\n at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nLogin\nAppBiz, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null\nMyApp.LoginBiz\nMyApp.User Login()","HResult":-2146233079,"Source":"AppBiz","WatsonBuckets":null}
 
 
Thanks
Closed May 27, 2012 at 7:49 AM by JamesNK
Works for me

comments