mail for ASP.NET email smtp mail for ASP.NET email smtp
mail for ASP.NET email smtp

Other Products
mail for ASP.NET email smtp
  "WOW! I just read the upgrade list. I'm going to upgrade now! aspNetEMail rocks! Thanks for the update."
Jeff H.
 
   More Testimonies

Why can't I uninstall my assembly?

by Alan Shi
This article can be found here, we only host it, in case the link is down, and our customers want to immediately read it. We suggest you check the live article, for any updates.

When installing an assembly to the GAC, Fusion provides a mechanism for the installer to specify a traced reference count on the assembly being installed. The idea is that if the same assembly is installed multiple times by different clients, the assembly is not removed until all of the clients that installed the assembly have explicitly requested uninstall. Without such a feature, you could run into scenarios where assemblies are prematurely uninstalled. For example: two applications install the same shared assembly to the GAC; one application is uninstalled, and the shared assembly is removed even though another app still needs it.

The reference counts Fusion provides are called “traced” reference counts, because unlike COM reference counts, which simply record the number of outstanding clients, an installer is allowed to specify information identifying who needs the particular assembly. There are different kinds of traced reference counts that an installer can provide, such as a filepath, or an opaque string that is installer-specified. Gacutil allows you to specify traced reference counts in an install command-line via the /r option.

You can read more about traced reference counts in this gacutil MSDN document. There is also information about traced reference count in our support article describing the unmanaged Fusion API.

When you install your assembly using MSI (which is the recommended approach for retail installs), there is no need to specify a traced reference count for your assembly, because MSI has its own internal reference counting mechanism. When Fusion is asked to uninstall an assembly from the GAC, it will check if there are any outstanding traced reference counts. If there aren't any traced reference counts, Fusion will call a Windows Installer API to determine whether or not MSI holds a reference on the assembly. If any reference count (traced reference count, or MSI reference count) exists, the assembly will not be uninstalled.

If you try to uninstall an assembly in the GAC using “gacutil -u”, you may see a message indicating that some traced reference count remains on the assembly, and gacutil will output the information about the pending traced reference count. In order to uninstall it, you must remove all the traced reference counts. For MSI-installed assemblies, this is only possible by uninstalling the MSI package that installed the assembly via Add/Remove programs.

Some customers have reported unusual cases where an assembly installed into the GAC via gacutil without a traced reference count, can later not be uninstalled via “gacutil -u“. When the uninstall is attempted, the following message appears:

Unable to uninstall: assembly is required by one or more applications Pending references:

SCHEME: <WINDOWS_INSTALLER> ID: <MSI> DESCRIPTION:<Windows Installer>

This message is informing the user that Fusion thinks that Windows Installer holds a reference count on the assembly, yet this information is clearly wrong because the assembly was never installed via MSI.

If you encounter this problem, it is very likely that you have run into an odd MSI registry corruption (at the time of this writing, the cause is unknown). Without getting into a long-winded explanation of how this registry corruption eventually results in the error message above, the common cause of this is a bogus default value set under one (or both) of the below registry keys:

[HKCU\Software\Microsoft\Installer\Assemblies\Global]   

[HKLM\SOFTWARE\Classes\Installer\Assemblies\Global]

If these keys are not empty (e.g. they contain a MSI descriptor value), then you have hit this situation, and you should be able to fix the problem by clearing the default value. I can't guarantee that this will always work, but it has definitely been our experience that this is the most common source of this problem.

(This tip comes courtesy of our resident MSI expert on the Fusion team, Roberto Sciore).

posted on Wednesday, December 10, 2003 8:19 PM

Feedback

# re: Why can't I uninstall my assembly? 12/10/2003 8:29 PM Robert Hurlbut

Alan -- thank you for this tip. I recently came across this problem myself and found the same solution, but I wasn't sure if it was a "kosher" operation. Thank you for verifying my suspicions from a Fusion team member.

# re: Why can't I uninstall my assembly? 12/10/2003 8:53 PM Jeff Key

Ditto, thanks.

# re: Why can't I uninstall my assembly? 12/11/2003 1:30 AM Frans Bouma

Isn't it so that MSI is NOT the right choice for this because of this odd bug? IMHO when using MSI (it's easy to use, so why not use it) and you want to install to the GAC: shell out and run gacutil.exe to install the assembly. Requires more work, but you can be sure it will uninstall.

# re: Why can't I uninstall my assembly? 12/11/2003 3:06 AM Tomas Restrepo

Actually, the cause is not so unknown at all! One of our coworkers discovered this problem was consistently triggered by the MSN Messenger 6.0 installation!

# re: Why can't I uninstall my assembly? 12/11/2003 7:36 AM Rick Watson

We've reproduced the MSN Messenger behavior here at our company.

I've uninstalled that and installed Trillian instead [which can access MSN Messenger contacts]

# re: Why can't I uninstall my assembly? 12/11/2003 9:43 AM Alan Shi

Thanks for all the comments. I'll take the information you've provided about MSN Messenger 6.0 creating the corrupt MSI registry problem to the Windows Installer team so we can investigate further.

Frans, MSI is definitely the recommended way to install your assemblies (particularly in retail environments). The bug being described is a little orthogonal to choosing MSI as an installer; even if you shell out to gacutil.exe to install, doesn't guarantee the ability to uninstall (because the bug affects all uninstalls).

I'll be sure to let you all know when we get more information on this issue.

# re: Why can't I uninstall my assembly? 1/7/2004 1:03 PM Jason Aubrey

I have this same problem but both keys contain no values...

# re: Why can't I uninstall my assembly? 1/7/2004 2:09 PM Jason Aubrey

It seems that (in Win2KPro) executing the following froma commandline does the trick: rd /s <Assembly Name>

# re: Why can't I uninstall my assembly? 1/7/2004 2:12 PM Jason Aubrey

Maybe I should clarify... the "rd /s <Assembly Name>" should be executed from C:\WINNT\assembly\GAC

# re: Why can't I uninstall my assembly? 2/17/2004 1:29 AM george

I would appear to have the same problem but when I check the registry keys mentioned they are empty. I then attempted to manually delete the keys from a dos box I am unable to delete the directory. When I delve down into the directory I finally get to the actual DLL that has been installed, and it would appear that this file is locked in some way. Any thoughts??

# re: Why can't I uninstall my assembly? 2/17/2004 2:09 AM george

Success.

After a restart and deleting each file manually I was able to remove the files.

# re: Why can't I uninstall my assembly? 2/18/2004 8:58 PM Amit Ugane

Thanks It Works Really Good Solution

# re: Why can't I uninstall my assembly? 2/18/2004 8:59 PM Amit Ugane

Success

# re: Why can't I uninstall my assembly? 3/1/2004 8:23 PM Jerry Dennany

Alan - Thanks for this - I had this problem, and your advice was very helpful.

The box is not shipped.
aspNetEmail is a    
downloadable product.
 
aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Runner Up ASP.NET Email Control
Voted Runner Up Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetTraceRoute
Voted Runner Up Networking Control
Runner Up - Networking Control