Fog Creek Software
Discussion Board

Unloading COM objects from IIS?

In the article "Lord Palmerston on Programming," Joel mentions learning how to unload COM objects from memory without restarting IIS. Does anyone know how to do this?

Saturday, February 22, 2003

Make sure the application protection is set to High (Isolated). Then a unload of the applation is sufficient for unloading your COM objects and your other websites keep on running.

Jasper Kaizer
Saturday, February 22, 2003

Use MTS.

[I suspect that's why 50% of MTS users have it installed at all]


Philip Janus
Saturday, February 22, 2003

there's an "unload" button in Internet Services Manager, in the site properties. I never noticed it before.

Joel Spolsky
Saturday, February 22, 2003

Wow! You'd think that that would be more widely known, since it's such a pain to take the whole web service down to update a DLL. Thanks, Joel!

Saturday, February 22, 2003

It only works when the isolation level is "high" which means that the whole thing runs out of process. I discussed this with MS technical support a while back and they recommended against it, the unloading that is. I store the name of my component in an application level variable and change it after installing my new component. I uninstall the old one later after a restart. This is one of those problems which is resolved in .NOT

John Ridout
Sunday, February 23, 2003

It is always confusing as to how the marshalling works on out of proc servers.  I think it is serialized.  This could be a problem for objects which perform blocking I/O.  As ugly as it is, I currently have my Window's customers stop and restart their servers on the rare occastion that we need to patch their COM objects. 

Tight control over serialization is essential for my application to scale properly.  Serializing access to an operation that takes a second could be pretty ugly if you've got 300 people trying to make that same request.  Generally works fine on the desktop; horrible on the server.

I've grown to accept COM's architecture, but I'll always resent Microsoft's Apartment nomenclature.  Single, multithreaded, both?  Just tell me if access will be serialized or not.  That is the relevant part. 

web service admin/developer
Monday, February 24, 2003

Slightly OT:

When you run a web application under high isolation, it runs under an instance of dllhost.exe.  Does anyone know anything about how this process is launched (command line parameters, whatever)?  What IPC mechanism does it use?

The motivation is to run a web application under a profiler for real performace information.  Currently, the best way we've found to approximate this is by taking representative ASP files, putting the script parts into .vbs files, and profiling against them.  It can be informative, but it's not the real thing.

Would it work to have the profiler use dllhost.exe as the executable?  Would IIS "know" it's there, or launch another instance?  How do other people handle this?

Monday, February 24, 2003

A COM+ application can be started by:
  C:\Winnt\System32\Dllhost.exe /ProcessID:{<applicationID>}

Information on debugging COM+ applications in Visual C++:

BTW if an IIS application is configured as 'isolated' (i.e. uses COM+) one can just shut down the COM+ application (even using COMAdminCatalog from a script). However I've noticed that the very next call to the IIS application returns an error complaining about RPC. Following calls are OK.

Alexander Chalucov
Tuesday, February 25, 2003

>>A COM+ application can be started by:
  C:\Winnt\System32\Dllhost.exe /ProcessID:{<applicationID>}

I don't understand...  What is the COM+ application that you launch?  And how do you tell it what IIS web application it should be hosting?

Tuesday, February 25, 2003

> I don't understand... 
> What is the COM+ application that you launch?

  If you use high (isolated) application protection IIS creates a COM+ application with a name like:
  IIS-{Default Web Site//Root/tutorial}
In any case this name contains the name of your web application, so it should be pretty easy to find it. In order to use rundll.exe you have to get the GUID of this application (right-click the com+ application, properties, general tab, applicationID field).

> And how do you tell it what IIS web application it
> should be hosting?

When IIS tries to execute the ASP pages on your site, it will start the application it has created itself. If you have started it yourself - you win :) I have no idea what method of communication they use. Standard COM calls I assume, but I might be wrong if they opted for something faster.
BTW all the above applies to IIS5, not to IIS4.

Alexander Chalucov
Wednesday, February 26, 2003

*  Recent Topics

*  Fog Creek Home