title: C# Exception: Does it have an unique value/identifier
body: <p><strong>Does the class <code>Exception</code> have an unique Id or any other unique modifier (GUID,... )?</strong></p>
  
  <p>I'm logging the generated exceptions inside a backend-service. But my goal is to only log each exception once.</p>
  
  <p>Perhaps an example might of some use here:
  The Service has 3 layers:</p>
  
  <pre><code>DAL (SQL-Interaction)
          =&gt; Exception A occurs here and is being logged into the database
  
  BL (BusinessLayer)
           =&gt; Exception A is passed to here but isn't being logged
           =&gt; Exception B is thrown here and is being logged into the table
  
  Services (Service Interface)
           =&gt; Exception A is passed to here but isn't being logged
           =&gt; Exception B is passed to here but isn't being logged
  ...
  Client-solutions
  </code></pre>
  
  <p><strong>My current solution</strong> (which i personnally really don't like): </p>
  
  <blockquote>
    <p>I've written a own exception (inherits from the base class exception). when any exception is thrown for the first time then its being logged. Then its being cast to my own exception and rethrown. Exceptions of type of my own exceptions are nog logged in the database</p>
  </blockquote>
  
  <p>example (This is pseudo code)</p>
  
  <pre><code>DAL - Layer
       try{}
       catch (Exception e)
       {
            // log in database
            // log in logfile
            // Cast to OwnException
            // rethrown as OwnException
       }
  
  BL - Layer
       try{}
       catch (OwnException e)
       {
            // log in logfile
            // rethrow e
       }
       catch (Exception e)
       {
            // log in database
            // log in logfile
            // Cast to OwnException
            // rethrow as OwnException
       }
  </code></pre>
  
  <p>Update: What i'm actually looking for is an Id/unique modifier. I would scan the database for the presence of this id. And if this id isn't present then i would write a record. If its present then it would just be rethrown.</p>