Using Custom Assembly Installed in GAC

G

Guest

Using the GacUtil I created a SNK and deployed my assembly to the GAC using
the GACUTIL. When browsing to c:\[SystemRoot]\Assembly I can see my custom
assembly. However, how do I use it in a new project? I don't see it listed
as a component in the .NET Add reference section?

Also, why does MS say that the GacUtil is for development only? What do they
recommend using when moving production components to the gac?
 
K

Ken Cox [Microsoft MVP]

Hi Chris,

Hi Chris,

You can add a copy of the DLL to another location on your system and
reference it from there to keep you code happy and give you Intellisense
support. I often put it in the /bin folder. If there's a version in the GAC,
the executable will use the GAC copy at runtime.

Regarding the use of gacutil, I would suspect Microsoft is trying to tell
you to use Windows Installer technology to put production components in the
GAC.

Ken
Microsoft MVP [ASP.NET]
 
G

Guest

Hi Scott,

If I take your approach of placing the shared assembly in the applications
bin folder should I set the copy local=false? I assume that if this is set
to true, the assembly in the bin folder will be executed regardless of
whether or not it is in the GAC.

Second, how does the application determine whether to use the local assembly
or one from the GAC? I assume the GAC always has priority, ifso, how do you
allow the app to use the one in bin over the GAC, if assemblies exist in both
locations.

Thanks for your help!
Ken Cox said:
Hi Chris,

Hi Chris,

You can add a copy of the DLL to another location on your system and
reference it from there to keep you code happy and give you Intellisense
support. I often put it in the /bin folder. If there's a version in the GAC,
the executable will use the GAC copy at runtime.

Regarding the use of gacutil, I would suspect Microsoft is trying to tell
you to use Windows Installer technology to put production components in the
GAC.

Ken
Microsoft MVP [ASP.NET]

Chris Fink said:
Using the GacUtil I created a SNK and deployed my assembly to the GAC
using
the GACUTIL. When browsing to c:\[SystemRoot]\Assembly I can see my
custom
assembly. However, how do I use it in a new project? I don't see it
listed
as a component in the .NET Add reference section?

Also, why does MS say that the GacUtil is for development only? What do
they
recommend using when moving production components to the gac?
 
G

Guest

Just for reference, I tried setting copy local=false and I receive this error
at runtime even though it does exist in the GAC.

File or assembly name Applications.Library.IO, or one of its dependencies,
was not found.


Chris Fink said:
Hi Scott,

If I take your approach of placing the shared assembly in the applications
bin folder should I set the copy local=false? I assume that if this is set
to true, the assembly in the bin folder will be executed regardless of
whether or not it is in the GAC.

Second, how does the application determine whether to use the local assembly
or one from the GAC? I assume the GAC always has priority, ifso, how do you
allow the app to use the one in bin over the GAC, if assemblies exist in both
locations.

Thanks for your help!
Ken Cox said:
Hi Chris,

Hi Chris,

You can add a copy of the DLL to another location on your system and
reference it from there to keep you code happy and give you Intellisense
support. I often put it in the /bin folder. If there's a version in the GAC,
the executable will use the GAC copy at runtime.

Regarding the use of gacutil, I would suspect Microsoft is trying to tell
you to use Windows Installer technology to put production components in the
GAC.

Ken
Microsoft MVP [ASP.NET]

Chris Fink said:
Using the GacUtil I created a SNK and deployed my assembly to the GAC
using
the GACUTIL. When browsing to c:\[SystemRoot]\Assembly I can see my
custom
assembly. However, how do I use it in a new project? I don't see it
listed
as a component in the .NET Add reference section?

Also, why does MS say that the GacUtil is for development only? What do
they
recommend using when moving production components to the gac?
 
K

Ken Cox [Microsoft MVP]

For the first question, you don't need to copy local since you are only
using the DLL as a reference, not to run it from the local place.

As for the second, the executing program will always look in the gac first.
Here's a quote from this article:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbdev01/html/vb01g10.asp

"If I write a client program that references my shared.dll, the client
program stores the strong name for my shared.dll in its manifest. This means
that it can explicitly request my shared.dll and no one else's shared.dll.
Whenever the CLR is asked to load a class from a strong-named assembly, it
will always look in the GAC for that assembly. What's more, it will use the
information held in the client's manifest to identify the assembly based on
its strong name (which includes my identity), not just its filename. The
result: no chance of name clashes because a shared assembly is uniquely
identified by its strong name."

Ken
 
K

Ken Cox [Microsoft MVP]

Hey Chris, I don't recognize that as a .NET assembly name or namespace. Can
you post the code that requires it?

Ken


Chris Fink said:
Just for reference, I tried setting copy local=false and I receive this
error
at runtime even though it does exist in the GAC.

File or assembly name Applications.Library.IO, or one of its dependencies,
was not found.


Chris Fink said:
Hi Scott,

If I take your approach of placing the shared assembly in the
applications
bin folder should I set the copy local=false? I assume that if this is
set
to true, the assembly in the bin folder will be executed regardless of
whether or not it is in the GAC.

Second, how does the application determine whether to use the local
assembly
or one from the GAC? I assume the GAC always has priority, ifso, how do
you
allow the app to use the one in bin over the GAC, if assemblies exist in
both
locations.

Thanks for your help!
Ken Cox said:
Hi Chris,

Hi Chris,

You can add a copy of the DLL to another location on your system and
reference it from there to keep you code happy and give you
Intellisense
support. I often put it in the /bin folder. If there's a version in the
GAC,
the executable will use the GAC copy at runtime.

Regarding the use of gacutil, I would suspect Microsoft is trying to
tell
you to use Windows Installer technology to put production components in
the
GAC.

Ken
Microsoft MVP [ASP.NET]

Using the GacUtil I created a SNK and deployed my assembly to the GAC
using
the GACUTIL. When browsing to c:\[SystemRoot]\Assembly I can see my
custom
assembly. However, how do I use it in a new project? I don't see it
listed
as a component in the .NET Add reference section?

Also, why does MS say that the GacUtil is for development only? What
do
they
recommend using when moving production components to the gac?
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top