3

I have moved a few assemblies to the Global Assembly Cache because they are used by multiple applications i.e. a VB.NET app and an ASP.NET app.

I remember a few years ago when I started in my current role I noticed that the previous developer registered COM DLLs in the System32 folder. I asked about this and Hans Passant replied saying this was poor practice because System32 is for Operating System DLLs. Is it bad practice to register assemblies in the GAC for similar reasons?

My understanding is: if a .NET DLL is accessed my 2 or more applications then put it in the GAC.

4
5

I would recommend Staying away from the GAC as much as you can. Different assembly versions don't always play nice and debugging that can be a real PIA.

From a technical point if two apps use an assembly it is acceptable to place it in the GAC.

In real world usage, the few Kilobites of saved space is not worth the weeks/months of debugging a GAC dependency problem. It's much better (in real practice) to keep an app and it's dependencies as isolated as possible.

3

I would say yes, using the GAC is a "bad practice"... Or better put, it's not a recommended practice for most situations. Case and point, the next version of ASP.NET doesn't even use the GAC (http://blogs.msdn.com/b/webdev/archive/2014/05/13/asp-net-vnext-the-future-of-net-on-the-server.aspx).

Some other reasons the GAC is a bad idea:

  • Deploying assemblies into the GAC can be difficult.
  • Versioning assemblies in GAC can be difficult.
  • Configuring permissions to assemblies can be difficult.

And, if anything, my personal experience with the GAC has lead me to avoid it at all costs... :)

0

Using the GAC isn't bad per se (in some situations it may even be required), but you should know what you're doing.

However, some quick tips;

  • Don't deploy to the GAC if the machine is not yours to command.
  • Don't deploy to the GAC if you don't use assembly versioning.
  • Don't deploy to the GAC if you can just use a local bin folder.
  • Don't deploy to the GAC if you want to use multiple distinct versions in different locations on the machine (unless they differ in major.minor version).

That said;

I wouldn't deploy to the GAC for an ASP.NET scenario. Just use the bin folder in the web application path. Note that ASP.NET looks into the local bin folder before looking in the GAC as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.