title: "COM object that has been separated from its underlying RCW cannot be used" with .NET 4.0
body: <p>I've a class in my .NET 3.5 C# WinForms application which has five methods.
  Each method uses different sets of C++ COM interfaces.
  Am using <code>Marshal.FinalReleaseCOMObject</code> for cleaning up these COM objects. This code works fine on this .NET platform without any issues.
  But when I move this application to .NET 4.0, I start getting this error in one of these methods at a line where I cast a variable from <code>ICOMInterface1</code> to <code>ICOMInterface2</code>, i.e.:</p>
  
  <pre><code>ICOMInterface1  myVar= obj as ICOMInterface2; 
  </code></pre>
  
  <blockquote>
    <p>COM object that has been separated from its underlying RCW cannot be
    used.</p>
  </blockquote>
  
  <p>And if I remove the line where am using <code>Marshal.FinalReleaseCOMObject</code>, I don't get this error.</p>
  
  <p>What am I missing here? And how do I clean up these unmanaged COM objects from the memory on .NET 4.0 platform?</p>