Thursday, Mar 11, 2004, 8:08 AM
Avoid the GAC (and Check My Reasoning)
The one where I can only come up with two reasons for using the GAC, the first being very difficult to pull off correctly and the second to happen more and more rarely as we move to SOA and .NET.
This post feels very much like "Why do we still need duals?" so if you've got a reason for using the GAC that I didn't list, by all means, let me know!
37 comments on this post
Michael:
Thursday, Mar 11, 2004, 8:14 AM
Tommy Williams:
Thursday, Mar 11, 2004, 8:24 AM
Josh:
I created a new configuration section handler that is defined in MACHINE.CONFIG so that all apps on the server use it. In that case, I felt it was best to put the section handler code in the GAC. Since apps that use it don't have a reference in their web.config, why should they have to have a copy in their bin folder as well? The effect is that the section handler is completely transparent to the app.
Thursday, Mar 11, 2004, 8:37 AM
Chris Sells:
Tommy says "Avoid support costs for ISPs." That's not a technical reason, but a good one.
Josh says, "Extending the platform seamlessly." I admit that "seamless" is pretty compelling, but remember that you're on the hook for backwards compatibility if any of those apps program against your types.
Thursday, Mar 11, 2004, 8:49 AM
Mike Dimmick:
Be aware that a signed DLL has a different search algorithm to an unsigned one. The system will check the GAC first, then any paths configured, only finally ending up in the same path as the calling component. This caught out someone I was on a course with a few months back; administrators were 'fixing' a broken system by placing a component in the GAC, which wasn't then being upgraded properly. My recommendation is to sign it and install in the GAC, or don't sign it at all - then the admin cannot ever put it in the GAC.
For our new version PIAs, I've created publisher policies to allow components built against the previous version to run on the new one without needing the previous version PIAs. The Publisher Policy documentation could do with, well, I was going to say a polish, but it could actually do with rewriting - it's inaccurate and unclear.
Thursday, Mar 11, 2004, 8:51 AM
Onorio Catenacci:
When you're doing an xcopy deployment, why not just statically link an entire executable image? I mean, I guess you could argue that building some functionality into dll's allows you to upgrade that part of the functionality without having to send along the whole exe but honestly, how much less trouble is it to install a new dll than it is to install a new version of the app?
Dynamic Linking, at least as it's currently implemented, seems to be a technology that has not met the cost/benefit test. That is, the cost of using the technology seems to outweigh any benefits that its use confers.
--
Onorio Catenacci
Thursday, Mar 11, 2004, 9:21 AM
Jose Simon :
We are using it like Tommy and Josh tell.
We host lot of different applications in a server but these applications share some common things like i.e. http handlers for authentication and compression etc. Usin the GAC allows us a better control of this common code rather that need to copy the same dlls again and again, with the problems for updating each one when something changes.
I dont feel the hook for backwards compatibility as if we need to change something in new version we can have both versions in the GAC and each application will continue using the correct one, that is quite similar situation at the one we have if we copy the dlls on each application but with easier control, or am I missing something?.
Regards ,
Jose
Thursday, Mar 11, 2004, 9:33 AM
Greg Reinacker:
Thursday, Mar 11, 2004, 9:35 AM
Chris Tavares:
I was building two assemblies - we'll call them A.dll and B.dll. B had a bunch of IComponent implementations in it, and I wanted to be able to have this DLL show up in VS.NET's assembly search box by default (the box that shows up with the list of "known assemblies" when you right click and do "add reference" or "customize toolbox").
All you need to do that is to set up a couple registry entries. I did that, and voila, there was my assembly. But there was a catch.
You see, B.dll depends on A.dll. Despite the fact that both DLL's were in the same directory, when VS.NET tried to load assembly B, it didn't find assembly A. So I couldn't use my lovingly crafted components from the toolbox as they were designed.
The solution? Put 'em in the GAC, then VS.NET could load the darn thing and everything worked.
Thursday, Mar 11, 2004, 10:33 AM
Andy Reeves:
1. Assemblies load from the GAC faster – no security check (they were checked when they were added)
2. If you are loading a .NET assembly from a COM+ process then where does fusion look to load the dll's? In the System32 folder. You don’t want to xcopy your assemblies into system32
3. If you are writing an enterprise app that will be the only app on the boxes you will have done the testing and you may need to share your assemblies across many processes. i.e. Windows Services, COM+ apps, BizTalk, a WebSite etc. Some of these may be on the same box and if you use xcopy you'll have the same dll in multiple places on the same box.
4. If you write a BizTalk AIC in .NET your library assembly will be loaded into the BizTalk process. Where will it look to load your assemblies from? The location of the BizTalk service exe. You don’t want to have to install your own assemblies in another products folders.
Thursday, Mar 11, 2004, 12:21 PM
Adrian Bateman:
Thursday, Mar 11, 2004, 12:27 PM
mikeb:
We could not get them instantiated via COM unless they were in the GAC - specifying a codebase parameter when registering the assemblies did not work for some reason.
Thursday, Mar 11, 2004, 4:59 PM
Jon Flanders:
Thursday, Mar 11, 2004, 6:15 PM
Eddy Recio:
I could be mistaken but I was thinking of security. As some folks have pointed out about ASP.NET sharing DLL’s, but more specifically, if an app needs a certain level of permissions (Code Access Security rights) like File IO but the rest of the App has can have lower rights. One could foreseeably install the component into the GAC with elevated rights (may be run under partial trust) and call that component from the rest of the app that would have lower permissions, preventing opening up the security to the entire App that was XCopied. I guess this is the shared idea but with a security twist.
As for the faster execution and all those arguments, well 4Ghz are probably around the corner and most of the times the bottleneck for apps is memory. Besides make the pretty Splash screen display a nano second longer.
Just some thoughts.
Thursday, Mar 11, 2004, 8:03 PM
Fumiaki Yoshimatsu:
Thursday, Mar 11, 2004, 11:18 PM
miha at rthand com (Miha Markic [MVP C#]):
I think ILMerge does just that and more - it packs assemblies into one so you end up with one executable if you want to.
http://research.microsoft.com/~mbarnett/ilmerge.aspx
Friday, Mar 12, 2004, 5:07 AM
miha at rthand com (Miha Markic [MVP C#]):
Friday, Mar 12, 2004, 5:08 AM
Daniel Petersson:
Using ngen puts the code into the gac...
or atleast the native image... but sofar the only company that uses ngen on a wide basis is MS and all their stuff is alread in the GAC so they probably doesn't care...
Friday, Mar 12, 2004, 5:22 AM
David Cornelson:
Is it possible that the way things are designed is a flaw in Microsoft's thinking? I've been using MS stuff for a long time and there has rarely been any high level interest configuration management and easing the pain of deployment and infrastructure management.
.NET has designed some ways to ease the pain, but still, is there a top to bottom push for helping developers manage code and the resulting deliverables? I see a few development tools coming down the pipe (MS-Build), but VSS is still the company standard and is ancient.
This is where the Rational ClearCase folks, although possibly overkill, have really lept ahead of MS's thinking.
Config management is something that should be considered while you're building Whidbey and Longhorn. And not just from a developer's point of view. What other roles can be identified?
I think the underlying concern that Chris has is that the resulting duel system really comes from a lack of plan in the past.
Is this wrong?
Saturday, Mar 13, 2004, 9:59 PM
Ian Griffiths:
http://www.interact-sw.co.uk/iangblog/2004/03/17/usethegacluke
(Now I get to find out whether Chris's comment software automatically detects and blocks URLs...)
Wednesday, Mar 17, 2004, 2:37 AM
Rick Hallihan:
Wednesday, Mar 17, 2004, 11:49 AM
Rick Hallihan:
Wednesday, Mar 17, 2004, 11:53 AM
Junfeng Zhang:
Of course if you are talking to application developers, I'll buy that. But, please don't generalize your conclusion.
Wednesday, Mar 17, 2004, 11:58 PM
Shawn A. Van Ness:
My take: this sxs versioning business is awfully complicated. And adding complexity to the development and deployment of software has never, since I can remember, made for a better end-user experience.
In the end, I'm not sure sxs is any better than COM's "thou shalt not break app-compat" versioning scheme. We've always been free to bump our CLSIDs, if we're afraid of that responsibility...
Thursday, Mar 18, 2004, 12:58 PM
Hussein:
1-side-by-side deployment and execution
2-improved loading time
3-reduced memory consumption
4-improved search time
5-integrity checking (install time)
6-file security
Thursday, Mar 18, 2004, 5:46 PM
IanG:
Thursday, Mar 18, 2004, 10:10 PM
Chris Sells:
[1] http://geekswithblogs.net/mtreadwell/archive/2004/03/28/3473.aspx
[2] http://weblogs.asp.net/junfeng/archive/2004/03/29/100777.aspx
[3] http://blogs.msdn.com/alanshi/archive/2004/03/28/100765.aspx
Monday, Mar 29, 2004, 1:07 PM
Stephen Johnston:
Monday, Mar 29, 2004, 1:16 PM
Chris Sells:
[1] http://www.neward.net/ted/weblog/index.jsp?date=20040329#1080551172872
Monday, Mar 29, 2004, 8:06 PM
Eric Newton (eric.at.ensoft-software.com):
Build a Class Library Tools.dll, v1.0
Build an asp.net app against Tools.dll,v1.0
Build a webcontrols library against Tools.dll,v1.0
Now, add some more Tools to the Tools.dll, and move to v1.1
If your original AspNet app references ClassLibrary, it has to pull Tools.dll [v1.0] into its bin, but when you go to pull the NEW WebControls w/Tools.dll[v1.1], the v1.1 overwrites v1.0
Read that very carefully, I didnt really have enough time to elaborate. But in essense I believe SxS assemblies are missing one major thing: their Version number in the filename!
Monday, Apr 26, 2004, 2:28 PM
Phil Wilson:
http://blogs.msdn.com/alanshi/archive/2004/03/28/100765.aspx
Wednesday, Jul 14, 2004, 5:15 PM
Brent Rockwood:
Monday, Nov 29, 2004, 6:58 AM
Ram (ninja@bezeqint.net):
In example lets take an ASP.NET application that uses COM+ (ServicedComponent).
If there are assemblies that are shared for both layers (I.E: ValueObjects).
Registering these assemblies in the GAC saves a big headach...
Saturday, May 21, 2005, 11:01 PM
GAc:Fusion and usefulness:
1. when i need to provide an important fix to my app.
2.More then true when i need to supply backward compatibilty and my assembly to run in full trust.
3.whenever i needto share a componet between different app(no other way here).
Even though there is significant concern as raised by chris the more is with the approach we followed for our deployment and chris is true to certain extent so as few other's who made commnets in alan shi's response regd the fact that there is no other option to provide a publisher policy for the updates and which is many times a tedious task and there is many problems for related to the same .
However without GAC also some we could have asked for the fact why there is no option avalable for backward compatibility and componet sharing and the GAC hell due to the wrong implementation is far better then DLL hell which we suffered and the Binary compatibility of COM was too tedious and subject to more design restriction then the gac .atleast we can ship the publisher policy separately to avoid the same with few restriction.
Howvere even though the purpose of GAC and the usefull ness of the same are questionable with the above two discussion i found it quite astonishing as how both chris and alan didn't have the issue realted to the dependent assembly load and the control and issue related to using partial load,assembly.load as well as the assembly.loadfrom.
The trust level associated and the way the assembly were searched when it is local ,when it is loaded in a shared network and when it has few dependent assembly has significant changes when we are dealing with private assembly and Gaced assembly
Also when you use reflection to load an assembly and the dependent assembly the gaced and non gaced assembly behaves differently when the assembly are in diff domain as wella s in same domain but out of private path.
PLease commenet on the same.
sndshreeman@rediffmail.com
http://spaces.msn.com/members/shreeman
Sunday, Jun 26, 2005, 10:27 AM
:
Tuesday, Jan 31, 2006, 4:18 AM
Harshit:
Friday, Mar 2, 2007, 4:57 PM
Ranjeet:
It does not seem like the GAC Hell issue is still being discussed, but I am facing the same question in my organization and had some thoughts on this.
The problems you have described, will they be addressed if the GAC somehow has a reverse lookup to find out assempblies using a specific version? I think MS still suggests GAC because they expect applications to have their own trace of what versions are being used by what consumers
thanks
Wednesday, Feb 6, 2008, 5:19 PM




