Unit testing: COM object that has been separated from its underlying RCW cannot be used

Let’s say you’re writing unit tests for code which uses COM objects. You want some initialization and some cleanup to be done. So you set up your test: private static MyStore store; [ClassInitialize()] public static void MyClassInitialize(TestContext testContext) { store = new MyStore(“some value”); } [ClassCleanup] public static void MyClassCleanup() { store.DoWork(someArgument); } However, as…

2