AnsweredAssumed Answered

LicenseInitializer does not work under unit testing with MSTest

Question asked by kor_ on May 15, 2012
Latest reply on Nov 6, 2012 by kor_
I have set up a unit testing class for our ArcMap extension. I need the ArcObjects for generating sample geometry objects etc. And for that I need the LicenseInitializer. Everything works fine for the first test, but the second test always fails at error:
Error: System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used..  at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, ref Boolean pfNeedsRelease) at ESRI.ArcGIS.UCOMIArcGISVersion.GetActiveVersion(ref esriProductCode code, ref String ver, ref String path) at ESRI.ArcGIS.RuntimeManager.get_ActiveRuntime() at UnitTestHelpers.LicenseInitializer.InitializeApplication(esriLicenseProductCode[] productCodes, esriLicenseExtensionCode[] extensionLics) in LicenseInitializer.Designer.cs: line 50


If I run just one test, everything works ok, but it's the second test that causes the error. I also noticed that if I debug the test and pause it for a while, then the error also rises. But if I just run the test without any interruptions, it runs fine.

How should I create and shutdown the initializer properly? Any other suggestions how to make this working?

Outcomes