ManagementClass.GetInstances() throws COM exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

We have created a custom adapter for Microsoft BizTalk using C#. We wish to
add the adapter to the BizTalk adapters list automatically upon install and
remove it on uninstall. We found this code, which seemed to do exactly what
we want:

geekswithblogs.net/cmcneill/ archive/2005/04/05/28336.aspx

However, when running the Uninstall method, an exception is thrown at the
line:

ManagementObjectCollection adapterObjects = adapterClass.GetInstances();

The exception is: "System.Runtime.InteropServices.InvalidComObjectException:
COM object
that has been separated from its underlying RCW can not be used"

Now, just for kicks I decided to install SP1 for .NET framework 1.1, and
voila, no exception. However, it seems a ridiculous requirement to have this
service pack installed just to run this one function that is only called
once on uninstall. Is there any other way to get around this problem (and
what is the problem anyways??) . Any insight on this is appreciated.
 
Back
Top