title: COM-object was released unintendedly
body: <p>I have a helper-class for my unit-tests that share a reference to an COM-object in memory:</p>
  
  <pre><code>public class UnitTestGeometryProvider 
  {
      public static readonly IGeometry Geometry = Deserialize();
  }
  </code></pre>
  
  <p>The geometry is deserialized from a Xml file which is stored as a resource file and appended to the project. Afterwards it is wrapped into a COM object:</p>
  
  <pre><code>public static IGeometry Deserialize() 
  {
      return (IGeometry) new XMLSerializerClass().LoadFromString(myXDoc.OuterXml, null, null);
  }
  </code></pre>
  
  <p>Now I have two test-methods that use the geometry stored within this class:</p>
  
  <pre><code>[TestClass()]
  public class MyTest
  {
      [TestMethod()]
      public void FirstTest()
      {
          var p = UnitTestGeometryProvider.Geometry;
      }   
  
      [TestMethod()]
      public void SecondTest()
      {
          var p = UnitTestGeometryProvider.Geometry;
      }
  }
  </code></pre>
  
  <p>When running the second one I get a COMException:</p>
  
  <blockquote>
    <p>COM object that has been separated from its underlying RCW cannot be used</p>
  </blockquote>
  
  <p>I wonder why the reference to the COM-object is released as it is marked <code>static</code> in <code>UnitTestGeometryProvider</code> and I do not explicitly release it. So even <em>if</em> the <strong>managed resource</strong> to the instance would go out of scope (which is does not at it is static), the underlying COM object should go away only when all my tests finished or more general when the application terminates, or do I miss anything?</p>
  
  <p>I am using ArcObjects and Visual NUnit.</p>