GAC assembly help needed

C

clinton

I have an VB.Net application that makes use of an assembly in the GAC.
Dont ask me why but i rebuilt the assembly (did not need to as made no
real changes. just tidied up some comments) Anyway once i did this it
must have created a new publickeytoken as my application is now
refusing to use the assembly in the gac. looks like it is expecting a
different publickeytoken. If i put the newly compiled dll in the GAC
all works well. I then have 2 assemblies in the GAC with the same name
AND version but different publickeytoken. the old one is no longer used
and the app uses the new one. the publickeytoken is the only
difference.

However to avoid a rollout of installing the new dll into the GAC on
400 PC's i was wondering if there is a way i can tell my application to
use the first assembly in the GAC (as no real change occured in the new
compile). I can remove the new compile from the GAC and simply tell my
app to use the original one. the difference here is the versions are
the same (as i have that set in my app.config file of the assembly)
ONLY the PublicKeyToken is different.

Not sure if this is possibly but thoughht i would ask. If it is not
possible, is the possible to have a poilcy created to install the new
file in the GAC (i.e the easiest way to install it on the 400 PC's
WITHOUT redoing the msi installer
 
C

Carlos J. Quintero [VB MVP]

You should be able to compile a new build with the same strong name than the
original. The strong name is composed of 4 parts: the name, version, culture
and public key token. If the name, culture and public key token are the
same, surely the app refuses to use new assembly because of the version:
change the AssemblyVersion attribute of the assemblyinfo file to the
original value (instead of using the * character to auto-increment). Also,
ensure that the app references the correct assembly.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
C

clinton

Thanks for the feedback. Unfortunately, the AssemblyVersion is the
same:

<Assembly: AssemblyVersion("1.0.2.0")>

what is different is the publicKeyToken. it must have created a new one
when i recompiled the assembly. now the application is requiring the
new one. i think it might have something to do with the assembly
manifest definition that the application is expecting. In the GAC they
look identical except for they different publickeytoken BUT my App will
not run against the original one. i even went as far as copying the
original dll out of the GAC to my c: drive, loading my app and pointing
the reference to the original version BOTH with Copy Local set to True
and to False
 
R

Richard Grimes [MVP]

clinton said:
I have an VB.Net application that makes use of an assembly in the GAC.
Dont ask me why but i rebuilt the assembly (did not need to as made no
real changes. just tidied up some comments) Anyway once i did this it
must have created a new publickeytoken as my application is now
refusing to use the assembly in the gac. looks like it is expecting a
different publickeytoken.

You can check this by looking at the assembly with ILDASM. This will
show the public key token of the assembly that it wants to call.
If i put the newly compiled dll in the GAC
all works well. I then have 2 assemblies in the GAC with the same name
AND version but different publickeytoken. the old one is no longer
used and the app uses the new one. the publickeytoken is the only
difference.

However to avoid a rollout of installing the new dll into the GAC on
400 PC's i was wondering if there is a way i can tell my application
to use the first assembly in the GAC (as no real change occured in
the new compile).

You have a problem with your compilation process. It sounds like the
compiler is picking up the wrong version of the library. Use Windows
Explorer, go to \windows\assembly then select the errant library and
right click and select properties. The CodeBase property should show
where the file was copied from when it was added to the GAC (the name is
a misnomer, the actual codebase is the GAC). Verify that this file is
the same version (ie use ILDASM and check the public key attribute).
I can remove the new compile from the GAC and
simply tell my app to use the original one. the difference here is
the versions are the same (as i have that set in my app.config file
of the assembly) ONLY the PublicKeyToken is different.

The app will only use the version it was compiled against, so this will
not work.

Take a look at my Fusion tutorial, you'll find all the gory details
there :)

Richard
 

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