Why the GAC?

G

Guest

If I install an assembly into the GAC, shouldn't I be able to reference it from new C# projects? How do I use an assembly that's been installed in the GAC? If I try to add a reference to it, it's not listed. If I navigate to the dll that I compiled and then installed in the GAC, then I'm not using the version that's in the GAC, right?

Obviously I'm confused about something... Can anyone shed some light? Thanks.

Jerry
 
D

Dave Sexton

Hi Jerry,

The GAC is really for registration, not storage. You'll have to reference the
assembly directly, but Visual Studio does supply a few means to show custom
assemblies in the ".NET" tab of the "Add Reference" dialog.

Add Reference Dialog of VS 2005 on MSDN:
http://msdn2.microsoft.com/en-us/library/ftcwa60a.aspx

--
Dave Sexton

If I install an assembly into the GAC, shouldn't I be able to reference it
from new C# projects? How do I use an assembly that's been installed in the
GAC? If I try to add a reference to it, it's not listed. If I navigate to
the dll that I compiled and then installed in the GAC, then I'm not using the
version that's in the GAC, right?

Obviously I'm confused about something... Can anyone shed some light?
Thanks.

Jerry
 
D

Dustin Campbell

If I install an assembly into the GAC, shouldn't I be able to
reference it from new C# projects? How do I use an assembly that's
been installed in the GAC? If I try to add a reference to it, it's
not listed. If I navigate to the dll that I compiled and then
installed in the GAC, then I'm not using the version that's in the
GAC, right?

Obviously I'm confused about something... Can anyone shed some light?
Thanks.

You can't compile against assemblies in the GAC. GAC'd assemblies are used
at runtime.

Best Regards,
Dustin Campbell
Developer Express Inc
 
D

Dave Sexton

Hi Jerry,

Sorry, I should have added, "during development" to "The GAC is really for
registration, not storage".
 
S

Scott M.

The assemblies you see in the Add Reference dialog are not necessarially all the assemblies registered in the GAC. Special steps have to be taken to see your assembly listed here. But, that doesn't mean you can't reference the assembly by browsing to it.
If I install an assembly into the GAC, shouldn't I be able to reference it from new C# projects? How do I use an assembly that's been installed in the GAC? If I try to add a reference to it, it's not listed. If I navigate to the dll that I compiled and then installed in the GAC, then I'm not using the version that's in the GAC, right?

Obviously I'm confused about something... Can anyone shed some light? Thanks.

Jerry
 
K

Kevin Yu [MSFT]

Hi Jerry,

As Dave suggested, you can use the following methods to make your assembly
displayed in the Add Reference dialog box.

1. Move or copy the assembly to the current project directory (you can find
these assemblies using the Browse tab), other project directories within
the same solution (you can find these assemblies using the Projects tab),
or the Public Assemblies folder at Program Files\Microsoft Visual Studio
.NET\Common7\IDE\Public Assemblies; (you can find these assemblies on the
.NET tab).

2. Set a reference path to the directory containing the assembly using the
Reference Paths Dialog Box (Visual Basic) or the Reference Paths Page,
Project Designer (C#, J#).

3. Set a registry key that specifies the location of assemblies to display.

In my opinion, if your assembly is a strong named assembly, you needn't put
it to GAC at development phase. You can put it to GAC when running. Because
at runtime, if your assembly is referencing a strong named assembly, it
will search in GAC first. If it is not found in GAC, it will look into the
local folder.

If anything is unclear, please feel free to let me know.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top