thlucas
Posts: 10
Joined: Mon Feb 09, 2004 3:30 pm
Location: Omaha, NE
Contact: Website

.NET Global Assembly Cache Refresh Problem

Hello AI Support,

I just purchased your Pro version of AI in June - I've been using the freeware up till then, and decided that I loved the product so much I had to have the Pro version. Keep up the good work ...

Now to my question:

Environment: VS 2003, Win2000 / XP, AI ver 3.0.1

I ran into a situation today which brought up a question of how AI handles refreshing a strong-named Assembly in the .NET Global Assembly Cache (GAC).

I have a strong-named assembly that I built, which I placed into the GAC via an AI MSI file. I ran the install, and it worked as expected on both Win2000 and WinXP. This was about 3 weeks ago - everything worked great, my ASP.NET web application works great, everything is A-OK!

I then make a small fix to my strong-named Assembly. The AssemblyVersion attribute is still the same, I just updated the code and did a Rebuild Solution in the VS 2003 IDE. I then rebuild my AI project to create a new MSI file. Prior to running the new MSI, I go to Add / Remove programs and Remove my previously installed program. I then run the new MSI and successfully install the updated Assembly into the GAC (or so I think). No error or reboot messages were issued by the installer.

I run my ASP.NET web application, expecting to see my fix - it's not there. The application is still using a cached copy of the Assembly in the GAC! I searched my local drive to ensure the .DLL was not anywhere else - only shows up in the C:\WinNT\Assembly\GAC.... folder. I also ensured that "Copy Local = False" is set in the "References" section of the ASP.NET project that uses my Assembly.

It seems like the MSI is not refreshing the GAC correctly with my updated Assembly. I was finally able to get it to work by performing the following steps:

1) uninstalled the original install.
2) manually uninstall the assembly from the GAC via a "GACUTIL.EXE /U AssemblyName" command.
3) ran an IISRESET command to stop / start ASP.NET.
4) ran the MSI to install the updated Assembly.

then it worked!

Is this something where I should force a reboot after the install, or is the MSI not refreshing the GAC correctly? Can someone explain how the Assembly portion of the install works - is AI creating an MSI that uses GACUTIL.EXE to update the GAC?

I also did a Control Panel Remove Program on my install, followed by a "GACUTIL /L AssemblyName" (list) command - it did not remove the Assembly from the GAC after the program was removed. I also rebooted, did the GAC list command again - the assembly is still in the GAC.

Thanks - Todd
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

Removal of assemblies from the cache is dependent to a list of clients for that assembly. The assembly can be removed only if Windows Installer is the last client of the assembly.

For more information on this please visit:

http://msdn.microsoft.com/library/defau ... _cache.asp

Also the old version might be required by some application on your system, that will not work with the new one. When updating an assembly Microsoft's guide line is:

"If all applications on the system must use the updated assembly, you should deploy a policy assembly. A policy assembly can redirect applications on the system to use the new assembly version. Policy assemblies should be provided by creating a new component."

If you want more details, please visit:

http://msdn.microsoft.com/library/defau ... mblies.asp

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
thlucas
Posts: 10
Joined: Mon Feb 09, 2004 3:30 pm
Location: Omaha, NE
Contact: Website

Hi Mike - Thanks for the quick reply.

I read the docs that you provided - they make sense. I understand the concept of "Pin"ing, which is similar to the old reference count method that pre .NET DLL's had to deal with. This answers my question about deleting an assembly.

I also read the doc about updating Assemblies in the GAC, and my question still remains:

"An in-place update overwrites the copy of a .NET Framework Assembly in the global assembly cache. This type of assembly update does not change the strong name of the assembly. Only the value in the FileVersion field of the MsiAssemblyName table is changed. The in-place update of a .NET Framework Assembly requires .NET Framework 1.1 or greater."

The fix I applied to my .NET Assembly was a minor 1-line change. I know for certain this is not going to break any other applications using the Assembly. I really don't want to spend alot of time creating a new strong-named assembly, then creating a patch to redirect the old strong-name to the new strong-name. I simply want to replace what's in the cache, and force a refresh so the change takes effect the next time an application requests the assembly from the cache.

My question: How does AI / Windows Installer handle refreshing the GAC?

I appreciate your time on this - not trying to be difficult, just trying to understand what's happening in the install process.

Thanks - Todd
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

I am afraid that in the end this is a .NET issue. Advanced Installer just provides an interface to the Windows Installer technology which does not implement a workaround for this issue.

My suggestion would be to use some kind of custom action to uninstall the assembly from the GAC.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Common Problems”