title: CLI/C++ Converting "this" pointer to an integer
body: <p>I am trying to trace managed object creation/disposing in a CLI/C++ prog:</p>
  
  <pre><code>::System::Diagnostics::Trace::WriteLine(String::Format(
      "Created {0} #{1:X8}", 
      this-&gt;GetType()-&gt;Name,
      ((UInt64)this).ToString()));
  </code></pre>
  
  <p>Which fails with</p>
  
  <p><code>error C2440: 'type cast' : cannot convert from 'MyType ^const ' to 'unsigned __int64'</code></p>
  
  <p>Is there a way to keep track of the unique object IDs this way?
  Thanks!</p>