Assembly strong name assertion

  • Thread starter Thread starter Sharon P
  • Start date Start date
S

Sharon P

Hi All
I need to assert that an assembly I address has the
appropriate strong name, before attempting to load and use it.
What is the best way to do this?
One method I can think of is to generate an AssemblyName object which
represents this assembly and than check it's name, version, and publickey
properties.
In order to assert this bublickey, I will compare it to the original key
that this assembly was
signed with.
I tried to get the original publickey from the *.snk file, using sn.exe but
the byte array I
get from it (using the 'sn -o keyFileName' option) is slightly different
than the one I get from AssemblyName.GetPublicKey();...

I want to use the key I get from 'sn -o keyFileName' as a hard coded
comparison criteria
if it was only identical to the one AssemblyName.GetPublicKey() returns.

BTW - I can not use the original *.snk file on run time for this matter.

Thanks for your attention

Rea
 
I tried to get the original publickey from the *.snk file, using sn.exe but
the byte array I
get from it (using the 'sn -o keyFileName' option) is slightly different
than the one I get from AssemblyName.GetPublicKey();...

First use Sn -p to extract only the public key from your key pair SNK
file, then run Sn -o on the new file.



Mattias
 
Back
Top