Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've registered a DLL in GAC. But I want to know how can I use the DLL.


Don't ask me to create a assembly object at runtime and proceed. I just want to add it to my project reference.

Also I found a alternate of adding the dll to the C:\Windows\Microsoft.Net\Framework\v.x.x.x\
and it's working. But here the another problem is copying the dll to the above said path is working without registering the dll to GAC.


All I just need is a way to add the dll already added in the GAC as a reference to my new project.

Thanks in advance.
Posted

When the assembly (it's assembly, not "DLL"; for .NET, this is no more than a name of the modules of one of the assemblies) is placed in GAC, you should not reference it by assembly location. From this moment, you have to reference it by its strong name. With Visual Studio, you will find it by name in the ".NET" tab of the "Add Reference" window.

—SA
 
Share this answer
 
Comments
chenthil28 10-May-13 16:02pm    
I couldn't find in the Add Reference .Net Tab.
Kindly help.
Sergey Alexandrovich Kryukov 10-May-13 16:10pm    
Just use some patience and attention. How do you usually add references in Visual Studio. You always use the window "Add References". From a context menu of the Solution Explorer node "References". I don't understand you: if you did not add references before, why would you develop anything for GAC, and, most strangely, how? Hope this is just some minor misunderstanding.
—SA
You must first understand why you want to place an assembly to the GAC at all: the GAC holds strong named signed assemblies of various versions. Each .NET executable looks up *at runtime* the directly or indirectly referenced assemblies in a well defined sequence, at one point also in the GAC. See How the Runtime Locates Assemblies[^].

When it is about *developing* such applications that depend on other assemblies, you can, but do not need to reference it from the GAC *at development time*. The reference is only used to first have access to the functionality exposed by the referenced assembly and secondly, to compile in the respective strong name into your application assembly. You may now have that assembly located in some persistent location (e.g. somewhere in ProgramFiles), then have it once registered in the GAC (running once as administrator: gacutil /i ...) and finally refer to the ProgramFiles assembly in your VS2010.

Note: the VS2010 does *not* compile in any path to an assembly. Neither do all the references in your project get their way into the assembly - only the really needed ones get compiled into the application.

E.g. if you run ildasm /text myApp.exe | more, and look for .extern, you see which assemblies with what version, etc. are referenced. No path there, only the name, version, culture, public token.

Cheers
Andi
 
Share this answer
 
v4
You should NEVER place anything in the C:\Windows\Microsoft.NET folders. They are strictly for the .NET Framework. It you have a shared library that's used by more than one application, then you can sign it and put it in the GAC or some other place as your requirements dictates, but NEVER under C:\Windows\Microsoft.NET.
 
Share this answer
 
Comments
Andreas Gieriet 10-May-13 16:57pm    
My 5!
Cheers
Andi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900