GAC Question

M

Mark Irvine

Hi,

When adding an assembly (using gacutil) to the GAC, does the source assembly
have to be in a specific place? The problem I have is as follows:

Created an assembley and a Strong Name
Source assembly is held in the bin directory of the web app
Try to run the code (even from other web apps) and all is well.
Change the location of the source dll, e.g. c:\shared, and register in the
GAC. The properties of the entry in the GAC confirm the new location.
Try to run the code an it does not work.

Can anyone help?

Mark
 
T

Teemu Keiski

Hi,

do you change the way assembly is referenced in the app after it is added to
the GAC? I.e do you use the version number etc?
 
M

Mark Irvine

Hi,

No, all I changed was the location of the assembly. From what I can tell,
from trying a few things, the location of the dll needs to be in a location
that is included in the Path environment variable. Does this seem correct?

Mark
 
W

Wolfgang Kaml

Mark,

Have you managed to get your code, better, assembly to work when it has been
added to the GAC and removed from the local /bin directory? From your
experience, can you tell, what is required? Can you confirm, that the
directory, in which your own assembly .dlls' are stored, had to be added to
the path, or was there something else necessary? e.g. a change of
machine.config, or aspnet.config, or web.config?

I stumbled into exact the same problem and reading all the newsgroups I see
that this is a quiet frequent problem. I can't believe that MS does not
offer a straight forward example on that. Nor can their support folks give a
simple and straight answer to that problem.

Thank you for your help!
Wolfgang
 
W

Wolfgang Kaml

Finally!!!

I have been able to figure it all out.

After the DLL has been added to the GAC (you will need to create a strongly
typed DLL to be able to add your DLL to the Global Assembly Cache GAC), you
have to add the DLL manually to the machine.config file that is located
under:
%systemroot%\Microsoft.net\Framework\<versionnumber>\config

The lines to be added have to be added in the following structure: (This
example adds the WebCounter.dll)
<configuration>
<system.web>
<compilation debug="false" explicit="true" defaultLanguage="vb">
<assemblies>
<add assembly="WebCounter, Version=1.0.1480.30047, Culture=neutral,
PublicKeyToken=c434ff78305dda8b" />
</assemblies>
</compilation>
</system.web>
</configuration>

Verson and PublicKeyToken can be retrieved from the GAC that is located
under:
%systemroot%\assembly
Locate your DLL that you have added to that store, and right click to check
the info in the properties.

BTW, a handy dandy idea is to add the following tool to your MS VS.NET
Development IDE:
(select menu "Tools" - "External Tools" - "Add")
Enter the following fields:
Title: "Create Assembly Ke&y File"
Command: "D:\Microsoft\Microsoft Visual Studio .NET
2003\SDK\v1.1\Bin\sn.exe" (needs to be adjusted to your drive and path for
sn.exe)
Arguments: "-k $(TargetDir)$(TargetName).snk"
Initital Directory: "$(TargetDir)"
Check the option: Output window (that will allow you to copy & paste the
output file after successful generation into the AssemblyKeyFile directive
of your AssemblyInfo.vb file.

From now on you will be able to select that command and the tool will create
the key pair file for you that will have to be added to the DLL project's
"AssemblyInfo.vb" file in the following line:
<Assembly:
AssemblyKeyFile("E:\Development\WebTools\WebCounter\obj\Release\WebCounter.s
nk")>

Hope that this info will help somebody to save a lot of trouble. I wished
that info would be available as a knowledge base article on MSDN.

All the best,
Wolfgang Kaml
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top