GAC'ing an assembly


G

Guest

Hello All,

I am trying to add an assembly to GAC but having difficult time figuring out
the concept of GAC. This is what I am trying to do....

1. Installed NUnit framework whose DLL ("nunit.framework.dll") I need to add
to the GAC so that I can use it from multiple applications.

2. Used the command "sn" to verify that the assembly is already strongly
named. Concluded that NUnit assembly is strongly named.

3. Used the command GACUtil to register the assembly in GAC.

Now when I expand the References node under the solution in VS.NET for my
web application I do not see the newly GAC'ed assembly. Does any one know why?

I thought that once I GAC'ed an assembly I do not have to add the reference
again from VS.NET. Am I wrong? Do I need to add the reference again to that
dll
from the Reference node in VS.NET?

Thanks for your help!!
 
Ad

Advertisements

M

Mythran

Diffident said:
Hello All,

I am trying to add an assembly to GAC but having difficult time figuring
out
the concept of GAC. This is what I am trying to do....

1. Installed NUnit framework whose DLL ("nunit.framework.dll") I need to
add
to the GAC so that I can use it from multiple applications.

2. Used the command "sn" to verify that the assembly is already strongly
named. Concluded that NUnit assembly is strongly named.

3. Used the command GACUtil to register the assembly in GAC.

Now when I expand the References node under the solution in VS.NET for my
web application I do not see the newly GAC'ed assembly. Does any one know
why?

I thought that once I GAC'ed an assembly I do not have to add the
reference
again from VS.NET. Am I wrong? Do I need to add the reference again to
that
dll
from the Reference node in VS.NET?

Thanks for your help!!

You can double-check to see if the assembly is in the gac:

Open Windows Explorer and navigate to %WINDIR%\Assembly
If the assembly is listed in that folder, then it is in the GAC. If it is
not listed, drag and drop the assembly into the folder (this is manual
registration of the assembly).

You do, in fact, need to reference the assembly from the GAC if you wish to
use the assembly (there are other ways of using GAC'ed assemblies, but
referencing them is the easiest).

HTH,

Mythran
 
G

Guest

You need to dump a copy in the C:\WINDOWS\Microsoft.NET\Framework\<version>
directory to have it show up in VS.NET.
 
M

Mythran

Aaron said:
You need to dump a copy in the
C:\WINDOWS\Microsoft.NET\Framework\<version>
directory to have it show up in VS.NET.

Not really. Another way to set a specific directory (mainly, a common
repository would be something like "C:\Program Files\Common Files\<company
name>") and dump all your assemblies that you create in there. Then create
the following registry key(s) / value(s):

Under the key "HKLM\Software\Microsoft\.NETFramework\AssemblyFolders",
create a new key with the companyname, or any other name you wish to give it
(this is just for uniqueness).

Set the default value for this new key to the path of the folder you created
above "C:\Program Files\Common Files\<company name>".

Now, any time you open the references dialog, it will look under the
directory "C:\Program Files\Common Files\<company name>" IN ADDITION to any
other directories it already looks (which includes the GAC).

HTH ;)

Mythran
 
G

Guest

What is the real advantage of an assembly that is GAC'ed if we have to add
the reference from each and every web application?

I thought that once an assembly is GAC'ed it would be available to all the
applications on that machine. So to make it visible to all the applications
do we have to add the reference from each and every app?

Thank you!
 
Ad

Advertisements

M

Mythran

Diffident said:
What is the real advantage of an assembly that is GAC'ed if we have to add
the reference from each and every web application?

I thought that once an assembly is GAC'ed it would be available to all the
applications on that machine. So to make it visible to all the
applications
do we have to add the reference from each and every app?

Thank you!

:

The advantage of a GAC'ed assembly is that you can use a single version of
an assembly in multiple applications without having to have a copy of that
assembly in their associated BIN folders. It also manages multiple versions
of an assembly, so you can have applications using multiple versions of the
assembly.

You do still need to reference the GAC'ed assemblies, but once referenced,
they aren't copied to the local bin folders (check the CopyLocal property of
the reference).

HTH,
Mythran
 
Ad

Advertisements


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