Detecting GAC assembly in use during uninstallation

  • Thread starter Thread starter Drew Liscomb
  • Start date Start date
D

Drew Liscomb

Fellow Frameworkers,

Our developer tools are a set of assemblies installed in
the GAC. I use InstallShield 8.0 to create an MSI-based
installer that installs the assemblies just fine, thanks.

My problem is that on uninstallation, an assembly
currently in use by a running application (IIS, for
example) is not detected. Instead, the uninstallation
seems to complete successfully, but the assembly in use is
left in the GAC.

I want to prevent uninstallation, or at least alert the
user if any of the assemblies is in use. How can I detect
a GAC assembly in use?

BTW, I tried searching (with another search engine) this
group for "uninstall assembly GAC" and the phrase "in use"
but the one hit was irrelevant. Also, I originally posted
in platformsdk.msi, and was directed here.

Drew Liscomb
Installer Engineer
MapInfo Corporation
 
Hello Drew,

Thanks for posting. I am still working on this issue and trying to
reproduce the situation. I am not sure how to make an assembly in GAC "in
use by another application". Could you kindly let me know your detailed
steps?

In my ASP.Net web application, I make reference to a class library assembly
in the GAC. To achieve this, I have to make reference to the same class
library outside GAC (with "Copy Local" set to false) to build and then
remove it. In my ASP.Net page, I add a button and use the very simple code
like the following:

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(new ClassLibrary9.Class1().Hello());
}

I close the IDE and open the page
"http://localhost/webapplication1/webform1.aspx" in IE. If I click the
button, a string value will be written to the page. Then I use the "gacutil
/u ClassLibrary9" command and attempt to remove the assembly from the GAC.
The command completes successfully and the assembly is removed. On the
other hand, the ASP.Net page is still working.

It seems that the application has loaded the assembly into the AppDomain
and does not hold the lock against the physical assembly in GAC. (The
shadow copy mechanism does not apply to assemblies in GAC.) Then I use
"iisreset" to restart the services and the web application no longer works.

I have repeated the test by installing the assembly into GAC via a MSI. The
same thing happens. I can remove the assembly with the uninstallation of
the MSI. The ASP.Net application can work without a physical copy of the
assembly for a while.

Is there anything wrong with my steps? I believe that we will be more
helpful if we can reproduce your situation. I look forward to hearing from
you.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top