Uninstall assemblies for .NET 2.0

Got a problem you cannot solve? Try here.
RikardG
Posts: 2
Joined: Wed Mar 29, 2006 2:55 am

Uninstall assemblies for .NET 2.0

Post by RikardG »

I'm installing some assemblies into the GAC and using the Install Assembly function. When uninstalling the product the assemblies in the GAC is not deleted.
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

They will be deleted as long as nothing else is using them - Windows Installer tracks all that internally.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
++good
Posts: 4
Joined: Mon Nov 07, 2005 5:55 am

Post by ++good »

>They will be deleted as long as nothing else is using them
I am not sure this is true. I created an installer that adds a single dll to the GAC. I then tested it on a clean virtual machine, fresh XP install with only the .NET runtime installed, and the uninstaller did not remove the dll. I am not sure if this is a bug with MSI or InstallAware.

Marcus
++good
Posts: 4
Joined: Mon Nov 07, 2005 5:55 am

Post by ++good »

Just tried it with Installshield Express, and it also doesn't remove the DLL from the GAC. I guess it is a MSI issues.

Marcus
Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Post by Gizm0 »

Actually the assembly is never removed, if you don't remove it by yourself..If you are sure that nothing else depends on it, you can use the .NET tools to remove it by command.
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
Install[b]Aware[/b] Software Corporation
cpursley
Posts: 2
Joined: Wed Aug 23, 2006 2:09 pm

Uninstalling assemblies placed in the GAC

Post by cpursley »

Since the install placed the assemblies in the GAC, it should also uninstall the assemblies from the GAC. I can't expect a common user to use a .NET removal tool and uninstall the correct assemblies. How do I automate the install to uninstall these assemeblies?
Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Re: Uninstalling assemblies placed in the GAC

Post by Gizm0 »

cpursley wrote:Since the install placed the assemblies in the GAC, it should also uninstall the assemblies from the GAC. I can't expect a common user to use a .NET removal tool and uninstall the correct assemblies. How do I automate the install to uninstall these assemeblies?
It is a .Net ISSUE, that something placed in the GAC it cannot be removed unless done by the removal tool of the framework.. You have to manualy call the tool for every assembly you want to remove.It's called InstallUtil.exe and it is located in the framework directory eg C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727. You call it like InstallUtil.exe /u assembly_name and it removes the assembly from the GAC if there is no dependency.
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
Install[b]Aware[/b] Software Corporation
cpursley
Posts: 2
Joined: Wed Aug 23, 2006 2:09 pm

Why doesn't InstallAware automate this process?

Post by cpursley »

Why doesn't InstallAware automate the process of assembly removal?
Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Re: Why doesn't InstallAware automate this process?

Post by Gizm0 »

cpursley wrote:Why doesn't InstallAware automate the process of assembly removal?
Because it is against the .Net GAC philoshopy?

If you force the uninstall of an assembly that already has a dependency on the same .dll (let's say you have the same version of a component by a 3rd party vendor) with another application, after uninstallation of your application and removal of the .dll, it will turn the other unusable.

Besides, Microsoft is very clear on that "Put in GAC whatever is going to "stay" on the target machine. Put in the same directory with your application, custom .dll's and stuff that are going to be removed on uninstallation".
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
Install[b]Aware[/b] Software Corporation
alma88
Posts: 38
Joined: Wed Apr 18, 2007 5:38 am

Post by alma88 »

Wise handles the removal of assemblies from the GAC without problem. That is, an assembly is removed as soon as all applications that use it are uninstalled. I just tried several combinations of installing/uninstalling different applications that use one or more of a common set of assemblies, monitored which assemblies are left in the GAC after removing each application, and confirmed that each assembly was properly removed when no application was referencing it any more.

I am spoiled on this since I just switched from Wise. How can I do the same with InstallAware?

Thanks,
Alexander
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

You can write MSIcode or a DLL or a plug-in which will forcibly uninstall assemblies from the GAC. This is not recommended. I think we had built a DLL like that for a client before, I can try to dig it up for you if you like.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
alma88
Posts: 38
Joined: Wed Apr 18, 2007 5:38 am

Post by alma88 »

Does this DLL reproduce the same functionality as the one I described -- I mean, with proper reference counting so that they are removed only when all apps are uninstalled?
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

No, I believe it forcibly removes everything that is referenced inside the MSI file.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
alma88
Posts: 38
Joined: Wed Apr 18, 2007 5:38 am

Post by alma88 »

MichaelNesmith wrote:They will be deleted as long as nothing else is using them - Windows Installer tracks all that internally.
Maybe I got it wrong and IA does what I want... Will IA delete the assemblies from the GAC upon uninstall if no other installation is referencing them?

Alexander
alma88
Posts: 38
Joined: Wed Apr 18, 2007 5:38 am

Post by alma88 »

Michael,

From "Removal of Assemblies from the Global Assembly Cache" http://msdn2.microsoft.com/en-us/library/aa371192.aspx:

The installer unpins the assembly when the last Windows Installer client is removed. If the Windows Installer is the last client of the assembly, the common language runtime provides the option to force a synchronous cleanup of the assembly.

This is exactly what I am looking for. From personal experience I know that Wise does it nicely. From reading the InstallShield reference I understand that it does it too; actually it even has a Permanent property that permits us to specify whether the assembly is to be removed or not once it's not referenced any more (http://support.installshield.com/kb/vie ... id=Q111094).

Your post from about a year ago indicates that IA does it too, but I can't find how to do it. Our IA-installed assemblies are never removed from the GAC. Can you please help me?

Alexander
Post Reply