Tuesday, November 25, 2008

Shutting Down a Running COM+ Instance

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.

internal static void ShutDown()
    Int32 count = 0;
    COMAdmin.COMAdminCatalog objAdmin = new COMAdmin.COMAdminCatalog();

    // WWB: ShutDown The Application (All Instances) Using teh Package Id

    // WWB: Iterate Over All Instances Making Sure They Are Shutdown
        count = 0;

        COMAdmin.COMAdminCatalogCollection  applicationInstances = 

        foreach (COMAdmin.COMAdminCatalogObject applicationInstance in applicationInstances)
            if (new Guid(applicationInstance.Name.ToString()) ==
                new Guid(ConfigurationManager.AppSettings["packageId"]))

        // WWB: Lets Wait Before Checking Again
        if (count>0)

    }while (count > 0);


Sunday, November 16, 2008

Mesh and IE Favorates

I have been playing around with Mesh a bit of late. Mostly good other than on a few of my machines, Mesh refused to install. Either the install itself failed or it just never allowed me to sign in.

But, I figured out one use for Mesh this morning that made it all come together: sharing IE Favorites. After installing Mesh, share the following folder on each machine:

Xp, 2003:
C:\Documents and Settings\%USERNAME%\Favorites\Links

Vista, 2008:

Make sure when resolving the share location of the folder on subsiquent machines, you browse to the location above.

Now your IE links are synced across machines.


Monday, November 3, 2008

Vista Administrator

In Vista there is an Administrator account, however it is disabled on install. If you join the domain you can login with any domain user you want, however if your domain connection is lost, your computer account or the domain lost then you can only login with the local user you created at install -- which can't be the Administrator. If you forget the the password to this user there is a problem. So to prevent a reinstall you need to enable the Administrator account with this:

Net user administrator /active:yes

at the command line under elevated permissions (Run As Administrator). The administrator password is blank (which means you don't have to login) by default.