473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
Jul 21 '05 #1
2 1449
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" <no***************************@hotmail.com> wrote in message
news:2g************@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

Jul 21 '05 #2
AssemblyName assemname = Assembly.LoadFrom(<assemblyfile>).GetName() ;
byte[] pubkey = assemname.GetPublicKey() ;

- Mitch

"Bob Rock" <no***************************@hotmail.com> wrote in message
news:2g************@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

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bob Rock | last post by:
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
4
by: Tamir Khason | last post by:
I have a form. On form there is my control (all of control's assemblies signed by strong key), BUT while running I recieve he located assembly 'MyFooAssembly' is not strongly named. While...
5
by: Oleg Subachev | last post by:
When I try to use strongly named assembly1 that references non-strongly named assembly2 I get the following error: "The located assembly '<assembly2 name>' is not strongly named." How can I...
0
by: inpuarg | last post by:
I have more then 5 projects in one solution. (c# VS 2005) GUI , BOL , DAL , Common Library , Extended Grid Component etc. All are compiled as strongly named assemblies. I am using public...
3
by: pranesh.nayak | last post by:
Hello group, I'm facing a problem in calling a signed .Net class library (c#) from VB6 exe. I have a VB6 exe calling .net assembly. The call to .Net dll works fine when i deploy the .Net...
2
by: Sky | last post by:
Hello: I'm trying to make sense of snk files, when to use, under what conditions to regenerate new ones,...can someone take a look if these statemes make sense? And then the final questions at the...
5
by: Lambuz | last post by:
First of all, is it possible usign .NET remoting feature inside a .NET applet loaded into a tag object inside an HTML page ? <OBJECT id="myID" height="150" width="300"...
26
by: Zytan | last post by:
What happens if I do this: static byte MemberFunction() instead of: public static byte MemberFunction() I know I can't access it. But what does it default to? Private? I can't find any code...
1
by: Tom | last post by:
My unsigned DLL works in my project that references it as long as I set Copy Local = true. Now I have signed the DLL with the sn.exe generated keys but have not yet moved the DLL into the GAC. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.