c# - Recreate Exception on client side -


i have exact same problem in recreate exception serialized in json response, have managed instantiate correct type of exception:

public class serviceexceptiondata {     public string type { get; set; }     public string message { get; set; }     public string errorcode { get; set; }     public string stacktrace { get; set; } } ... private static void handleserviceexception(serviceexceptiondata serviceexception) {    // exception type    type t = type.gettype(serviceexception.type);     // create exception instance    var exceptioninstance = activator.createinstance(t);     // set exception read-only properties: message, stacktrace    ??? 

i tried lot of things set properties, here of them:

but doesn't work.

the exception's properties defined as:

public virtual string message { get; } public virtual string stacktrace { get; } 

so there way set them once have exception instance (e.g. getting property's field , using setvaluedirect) or should give , create derived class , override properties give them public setters?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -