How can I overwrite a DLL?
How can I overwrite a DLL?
Door Michiel van Otegem
28 mei 2001
When IIS uses a DLL, the DLL is loaded in memory. As long as it isn't released from memory, the DLL is locked
and cannot be overwritten. So you need to unload the DLL from memory, how you can do that depends on the version
of Windows and Internet Information Server (IIS). In Windows NT 4.0, you also have the option to run the DLL under
Microsoft Transaction Server (MTX). In Windows 2000 this has been renamed to Windows Component Services (WCS).
Below is a description for each of the situations.
IIS version 3 (no MTX)
In order to unload the DLL, you need to stop the webservice. This can be done through Control Panel->Services or
with the Internet Service Manager. After the webservice has stopped, the DLL can be overwritten. When the
webservice restarts the new DLL is in place and will be used for subsequent calls.
IIS version 4 (without MTX)
If the DLL is not registered as an MTX package and the website(s) using the DLL do not run
in a separate memory space (check this with the Internet Service Manager), the same course of action as with IIS 3
is to be taken. Because of the complexity of the webservice in IIS 4, the easiest way to shutdown the webservice is
through Control Panel->Services.
If the DLL is not registered as an MTX package and the website(s) using the DLL all run in
a separate memory space, stopping those websites will suffice. The DLL can then be overwritten en the sites can be
restarted.
IIS version 4 (with MTX)
If the DLL is registered as an MTX package, the DLL will be unloaded after the amount of minutes set with the
Transaction Server Explorer for that package, after which you can overwrite the DLL. If the DLL hasn’t been
unloaded yet, you can force it to unload with the Transaction Server Explorer by choosing Shutdown (right click on
a package). After the new DLL is in place choose Refresh All Components (right click on the computer with the DLL).
There’s a catch however… the new DLL needs to be compiled with binary compatibility with the old DLL. If you don’t
do this, you have to unregister and remove the old DLL, place the new DLL, register it and import it into the right
package again.
IIS version 5 (without WCS)
If you run your DLL under IIS 5 without using WCS, you are in a spot off trouble. In my experience the DLL is only
released if the machine is restarted, although stopping most services should do the trick. Even stopping the entire
webservice didn't prove to be enough. A wise thing to do here is test your component in your development
environment (Visual Basic) thoroughly before using it in a website. (Note: If anybody does find a solution, please let
me knwo so I can add it here).
IIS version 5 (with WCS)
This situation is nearly identical to IIS 4 with MTX. You can find the WCS component manager under
Control Panel->Administrative Tools->Component Services. Caution! The new DLL needs to be binary
compatible with the old DLL.
|