Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple C# Data Algorithms Question - Populate class from Exception class
    text
    copied!<p>I am building this elobrate Logging solution for use in a government setting where things have to be done a certain way. One of the things is that we bubble up untrapped exceptions to the last point in Application_Error in global.asax where when of the things is that we get all the exceptions nested within the exception object and serialize that info to the database. There is code that walks the list. There is not one exception. There could be many nested exceptions. We build ASP.NET apps where we have this extensive bubble up exception logging system. A exception occurs. It bubbles up where another could happen, surrounding the other. It bubbles up to the last point - Application_Error in global.asax where there is all this logic that writes machine info to a database. An exception can occur during this which envelops the other exceptions</p> <p>In my case, WCF is involved ONLY because the systems involved are in separate zones and WCF is used to communicate. and you CANNOT serialize/pass an .NET Exception object across the service boundary so I have defined a C# class/Data Structure to represent exceptions:</p> <pre><code>[DataContract] public class ExceptionStructure { [DataMember] public string Message { get; set; } [DataMember] public string StackTrace { get; set; } [DataMember] public List&lt;ExceptionStructure&gt; InnerException { get; set; } } </code></pre> <p>First, Whoa, this structure may not work since InnerException is READ ONLY so I need help on a new class as well. I need only the Message and StackTrace fields as well as InnerExceptions.</p> <p>All I need help on is given an .NET exception object that may or may not have inner exceptions, can someone help me write the code that will populate one of these ExceptionStructure classes? </p> <p>Also, code to deserialize one of these into a list of .NET exceptions on the other side would be nice? If you see a better structure idea, feel free. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload