Tuesday, November 25, 2008

If you have an instance of object running under COM+ (in the dllhost.exe process space) and you want to shut it down from C#, you can use the code below. Note that ShutdownApplication only intializes the shutdown of the COM+ applicance, it will return sometimes before the application is finished shuting down. So you need to check to make sure the applicatio is shut down before continue. I use this code in my unit testing to kill the instance-- making sure that it is stateless. Also note that you need to send the package id for the application -- this is the guid you used when installing the application into COM+. It can be found on the first property page of the application properties in component manager.