Global Assembly Cache

S

Scott Stark

I took over a legacy e-commerce project that utilized.NET 1.1 to create the
website code and all associated assemblies. This code is used to power
around 75 web sites on a single web server. Right now they have a separate
directory for each store, complete with a \bin folder that contains about 20
DLL files. The \bin folder is replicated for each store, so we have about 70
copies (I'll explain the missing 5 in a second) of the same \bin directory
sitting around. When it comes time to make a change in the code, it's a
pain.

Here are my questions:

1) Can I simply drop these DLL files in the GAC (I'm aware of the
requirements for registering an assembly in the GAC) and then delete the
corresponding DLL files in the \bin folder for each site?

2) There are 5 or 6 sites that have had customizations performed to the
code. I do NOT want these few sites to load the assembly from the GAC,
rather I want them to continue to load the DLL in it's \bin folder. Can I
override the GAC files by simply keeping the custom DLL in the sites \bin
folder? If not, what's the recommended approach?

Remember, this is all .NET 1.1. :)

Thanks!

Scott
 
C

Chris Dunaway

2) There are 5 or 6 sites that have had customizations performed to the
code. I do NOT want these few sites to load the assembly from the GAC,
rather I want them to continue to load the DLL in it's \bin folder. Can I
override the GAC files by simply keeping the custom DLL in the sites \bin
folder? If not, what's the recommended approach?

I'm 100% certain, but I believe that the application will first look
in the app folder for the assembly before looking in the GAC. In any
case, you can install both versions of the assembly in the GAC and
then in the web.config file (or machine.config) you can redirect the
app to the correct version in the GAC.

Something like this:

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="assemblyName" culture=""
publicKeyToken="25283151a234958d"/>
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/</dependentAssembly>
</assemblyBinding>
</runtime>

Chris
 
A

Alberto Poblacion

Scott Stark said:
1) Can I simply drop these DLL files in the GAC (I'm aware of the
requirements for registering an assembly in the GAC) and then delete the
corresponding DLL files in the \bin folder for each site?

Yes.
Since you mention that you are already aware of the requirements, I
will not mention that the DLLs need to have a Strong Name :)
2) There are 5 or 6 sites that have had customizations performed to the
code. I do NOT want these few sites to load the assembly from the GAC,
rather I want them to continue to load the DLL in it's \bin folder. Can I
override the GAC files by simply keeping the custom DLL in the sites \bin
folder? If not, what's the recommended approach?
Remember, this is all .NET 1.1. :)

It's not that simple -- the GAC will take priority. The easiest approach
is to assign a different version number (using the
[assembly:AssemblyVersion(...)] attribute) to the customized DLLs. Each web
site will load the same version of the DLL with which it was compiled,
regardless of wether that version sits on the GAC or the bin folder.
 
S

Scott Stark

Hi Chris,

Thanks for the response.

I assume both versions of the DLL use the same strong name, they just differ
in their version numbers, correct? So 1.0.0.0 is my core DLL file and
2.0.0.0 is for Custom Store A, 3.0.0.0 is for Custom Store B, etc?

Then I'd update the web.config file as you suggested for the custom stores?
Do I need a redirect for version 1.0.0.0 on all the other stores (which one
does it use by default)? The only other question I have is how to generate
the code for web.config (publickeytoken, etc). Where does all that info come
from?

Sorry for the basic questions, haven't had much opportunity to deal with
this stuff before.

Thanks,

Scott
 
S

Scott Stark

Thank you! Between you and Chris, I think I've got my answers.

Alberto Poblacion said:
Scott Stark said:
1) Can I simply drop these DLL files in the GAC (I'm aware of the
requirements for registering an assembly in the GAC) and then delete the
corresponding DLL files in the \bin folder for each site?

Yes.
Since you mention that you are already aware of the requirements, I
will not mention that the DLLs need to have a Strong Name :)
2) There are 5 or 6 sites that have had customizations performed to the
code. I do NOT want these few sites to load the assembly from the GAC,
rather I want them to continue to load the DLL in it's \bin folder. Can I
override the GAC files by simply keeping the custom DLL in the sites \bin
folder? If not, what's the recommended approach?
Remember, this is all .NET 1.1. :)

It's not that simple -- the GAC will take priority. The easiest
approach is to assign a different version number (using the
[assembly:AssemblyVersion(...)] attribute) to the customized DLLs. Each
web site will load the same version of the DLL with which it was compiled,
regardless of wether that version sits on the GAC or the bin folder.
 
A

Alberto Poblacion

Scott Stark said:
I assume both versions of the DLL use the same strong name, they just
differ in their version numbers, correct?

You mean the same *key*. The version number is part of the Strong Name.

Then I'd update the web.config file as you suggested for the custom
stores? Do I need a redirect for version 1.0.0.0 on all the other stores
(which one does it use by default)? The only other question I have is how
to generate the code for web.config (publickeytoken, etc). Where does all
that info come from?

If you are using the Framework 1.1 you don't need to worry about
entering the assembly versions in web.config. Just Add a Reference to the
DLL you want to use, and build the project. The version number of the
Referenced DLL will be built into the main DLL that contains the code of
your website, so it will know which version to call.

Also, in your specific case, you don't want to redirect any DLLs to a
different version. This is precisely what you are trying to *avoid*, that
is, you want each site to use its own DLL (the one with which it was
compiled) instead of being redirected to a different version.
On the other hand, you could compile all sites with the same DLL, and
then add a Redirect in web.config to force a site to use a different version
at runtime.
 
S

Scott Stark

Hi Alberto,

Thanks for the explanations. In this case, I'm not referencing an assembly
within the project. It's the main website assembly (the one that contains
all the code-behind files from my ASPX pages) that I want in the GAC.
 
A

Alberto Poblacion

Scott Stark said:
Thanks for the explanations. In this case, I'm not referencing an assembly
within the project. It's the main website assembly (the one that contains
all the code-behind files from my ASPX pages) that I want in the GAC.

Ah. That's very different from what I had in mind. I'm not even sure
that this will work if you place it in the GAC. You will have to experiment
a little bit.
 

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