Note that there are some explanatory texts on larger screens.

plurals
  1. POClass creation memory load / anonymous classes
    primarykey
    data
    text
    <p>Working in an application and there's the following extension method listed for Exceptions:</p> <pre><code>public static void FillData(this Exception target, object data) { if (target == null) throw new ArgumentNullException("target"); if (data == null) throw new ArgumentNullException("data"); string stackTraceSite = target.LastStackTraceSite(); var stringDict = new System.Collections.Specialized.StringDictionary(); PropertyInfo[] pis = data.GetType().GetProperties(); int pisLen = pis.Length; for (int i = 0; i &lt; pisLen; i++) { string key = (stackTraceSite != null ? stackTraceSite + '.' : null) + pis[i].Name; try { target.Data[key] = pis[i].GetValue(data, null) ?? "null"; } catch (ArgumentException ae) { target.Data[key] = "ARGUMENT EXCEPTION -&gt; " + ae.Message; } } } </code></pre> <p>This is then called or used in a similar fashion:</p> <pre><code>try { // Perform some dangerous operation that throws an exception } catch (Exception ex) { ex.FillData(new { CustId = 4, Category = "Foo", Style = "bar" }); Logger.LogError(ex); } </code></pre> <p>The members of the anonymous type (as in the example) are "reused" in some cases, but in many other cases they are quite different. (e.g. <code>new { FileType = Enum.FileType.RejectionLetter, FilePath = loadFilePath }</code>)</p> <p>This sort of code is used in quite a few locations and in a web app that's going to get a lot of traffic.. one question I'm wondering is: will the definition of all those anonymous classes eventually bog down / crash / create a significant memory load even if / when they aren't being caught?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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