views:

416

answers:

3

I am new to ASP.NET having some basic doubts.

1) The public assemblies are deployed in GAC.Even when i go for "Add Reference ", I can

not point to c:\windows\assembly ( i hope it is not possible) .Still i need to refer the

assembly from ..\Bin folder of the source project ( custom assembly).Is there any consideration behind it?

2 ) Why exe is not allowed in GAC ?

+2  A: 

If you need to manually get to an assembly in the GAC, the easiest way I know of is to Start > Run > "C:\windows\assembly\gac_msil". There's a folder for each assembly in the GAC, so you can browse through there and find the exact path to the DLL you want, which will usually look something like:

C:\windows\assembly\GAC_MSIL\System.Net\3.5.0.0__b03f5f7f11d50a3a\System.Net.dll

Which is just name\version__publickey\filename.dll

There's probably a more "correct" way, so if someone knows what that is, please correct me!

As to the second question, I can only hypothesize. It does make sense that the GAC is for class libraries, not executables, but that's mostly philosophical. I don't know any technical arguments one way or the other.

Edit: that lovely first comment below the answer turned out to be a misunderstanding, and is resolved :)

Rex M
Rex, that is an awful suggestion, and unnecessary. You can add an GAC assembly using "Add Reference".
Henk Holterman
@henk how? If you reference an assembly in a physical location and it is also available in the GAC, it will of course be loaded from there. But if the assembly is only in the GAC, how else to reference it?
Rex M
Add references, .NET tab. Works in Project and Site templates.
Henk Holterman
@Henk hm. I'm not sure about that. The .NET tab does not list all the assemblies in the GAC - it is an aggregate of a predefined list of physical locations like the Framework folder, some various Program Files locations, etc. Most of those assemblies are *also* registered in the GAC, but not necessarily.
Rex M
Rex, OK, I will have to check my assumptions here. But not adding your own stuff to the GAC still helps a lot.
Henk Holterman
Generally though your assemblies must have existed somewhere on the file system to be deployed into the GAC - therefore you should be able to "Browse" to those locations and reference them from there - just make sure you turn off "Copy Local" on the property panel for the reference.
Zhaph - Ben Duguid
@Zhaph generally, yes, but that's not the question - the question is how to add from the GAC.
Rex M
A: 

Yes the GAC is for libraries because its used to establish global access to a set library. one that is shared with different applications. Why would you need an exe (an app) in the GAC? Understanding this may help with a better answer.

As for question 1, i am not sure what you are accessing. One concept people confuse is that the GAC is a not a physical location. It's just a registry. If you register in the gac it doens not move that dll into the framework directory.

Jonathan Kaufman
Actually the DLL's _are_ copied to the `assembly` folder.
Henk Holterman
ok yes I was texting while driving.(don't shoot, metaphor) but my main point was trying to discover the posters desire to put an exe in the GAC, I don't think it is what he thinks it is.
Jonathan Kaufman
A: 

Hi,

I've created a tool which is completely free, that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.

Hope this helps Muse VSExtensions

Muse VSExtensions