![]() |
Reading the public key inside a strongly signed assembly from the assembly itself???
Hello,
is it possible to programmatically read (and how) the public key that is embedded into an assembly that has been strongly signed??? What code would be needed??? Bob Rock |
Re: Reading the public key inside a strongly signed assembly from the assembly itself???
Bob,
The method below returns the key (if one is found) from any type's assembly. To use it to retrieve the current assembly's key, call it as follows (assuming you're calling from the class in which the method is declared): StrongNamePublicKeyBlob myKey = this.GetSigningKey(this.GetType()); HTH, Nicole public StrongNamePublicKeyBlob GetSigningKey(Type sourceType) { if (sourceType == null) throw new ArgumentNullException("sourceType"); StrongNamePublicKeyBlob retVal = null; foreach (object test in sourceType.Assembly.Evidence) { if (test is StrongName) { retVal = ((StrongName)test).PublicKey; break; } } return retVal; } "Bob Rock" <nospam.yet_another_apprentice@hotmail.com> wrote in message news:2gpreqF5hhuoU1@uni-berlin.de... > Hello, > > is it possible to programmatically read (and how) the public key that is > embedded into an assembly that has been strongly signed??? > What code would be needed??? > > Bob Rock > > |
Re: Reading the public key inside a strongly signed assembly from the assembly itself???
AssemblyName assemname = Assembly.LoadFrom(<assemblyfile>).GetName() ;
byte[] pubkey = assemname.GetPublicKey() ; - Mitch "Bob Rock" <nospam.yet_another_apprentice@hotmail.com> wrote in message news:2gpreqF5hhuoU1@uni-berlin.de... > Hello, > > is it possible to programmatically read (and how) the public key that is > embedded into an assembly that has been strongly signed??? > What code would be needed??? > > Bob Rock > > |
| All times are GMT. The time now is 08:47 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.