Saturday, January 22, 2011

Getting a Public Key Blob From 3rd Party Assemblies

The Return of Code Access Security

Working with SharePoint sometimes takes you to some pretty weird places. Code Access SecurityThere’s a lot of .NET’s surface area that I’m pretty sure I’d never have explored on my own if I hadn’t been tasked to do so via some SharePoint engagement.

One of these explorations has involved authoring custom CAS policies, the reasons for which I’ve blogged about in the past. Granted with the advent of SharePoint 2010 and sandboxed solutions it’s not as common a task these days, but it still comes up.

When authoring a custom CAS policy you’re taxed with obtaining the Public Key Blob from a Strong Name Key. This helps the .NET runtime identify assemblies (via their Strong Name) that you’d like to run with a particular code access security profile.

Now obtaining a public key blob is pretty straight forward if you have the .snk, but it gets a little more awkward if all you have is some 3rd party assembly. This is often the case when you want 3rd parties assembly (for us it was a bunch of Telerik Controls) to run in full trust. After all you don’t have their key and they’re super unlikely to give it to you.

Getting a Public Key Blob from a 3rd Party Assembly

1) First open up the Visual Studio Command Prompt (or optionally any command prompt, but have access to sn.exe which is typically found in Visual Studio’s SDK->BIN folder).

2) Run the following command:

sn -e [ThirdPartyAssembly.dll] publicKey.snk

This extracts the public key (and public key blob) into a file.

3) Then run:

sn -tp publicKey.snk

Which should display the public key blob and public key token (the blob is the long one).

Public Key Blob

At this point you can throw it in your own custom CAS file or resume whatever would make you seek out these awkward little strings in the first place.

Hope that helps. Had stare at the sn.exe docs for a good 10 minutes to find this and the web wasn’t all that helpful.

Happy CASing,


Unknown said...

Nice article, I think it will help me. Because I tried a lot of way's, and nothing gonna work yet. My friend told me that I need to restore some dll file, I only found the d3dx9_43.dll was missing, and upload again. Now all this working, but this was not the main problem.

Unknown said...

resort hotel mod

harish sharma said...

beetv apk


harish sharma said...

Redbox tv apk

gbapps said...

Thanks for sharing information. Your web-site is very cool. I am impressed by the details that you have on this blog. It reveals how nicely you perceive this subject..

YOWhatsApp 2020

ronald said...

The 25 alphanumeric code will be look like xxxxx-xxxxx-xxxxx-xxxxx-xxxxx . You can get this code by on the web and separated

mode both. You can purchase McAfee thing from or some other untouchable site or any endorsement place. If you

purchased your McAfee thing on the web, by then your 25 alphanumeric thing key will be sent to your enrolled email id. If you

purchased McAfee from retailer, by then your thing key will be in thing pack box.

shalley30 said...

Few steps for installing, and activating the Office setup. To enter the product key, click on

Raj Maan said...

how to train your dragon 3 123movies

GB Whatsapp said...

Your site has a lot of useful information for myself. I visit regularly. Hope to have more quality items. Also I would like to share some information also. Check out GBWhatsapp APK Download

Ethan said...

Wonderful post thanks for sharing GBWhatsApp Apk 2020 with us

Chiku said...

SSC Exam Result is a trending now in Bangladesh. SSC Examination was completed. All students are waiting to get their SSC Exam Result 2020. This year SSC Result 2020 will publish on 1st week in May. On the result day, after 12PM all students will get their SSC Exam Result 2020 from Bangladesh Education Board official website. Also Dakhil Result 2020 and SSC Vocational Result 2020 will publish on 6 May 2020

Chiku said...

SSC Exam Result 2020 in Bangladesh. SSC Result coming soon. All students are waiting to get their SSC Result 2020. This year SSC Result 2020 will publish on 06 May 2020. Students can collect their SSC Result 2020 from Bangladesh Education Board official website.

moviess said...


Anonymous said...

shayari pro

Aftab Shaikh said...

can we get fmwhatsapp & clash royale mod apk for free?

rice purity said...

You completely match our expectation and the variety of our download gbwhatsapp latest version

Anonymous said...

123movies. to invent a template language.

Anonymous said...

movies123 some of the advice driving me to abandon indentation

rice purity said...

Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share.

notepad plus download

rice purity said...

cool stuff you have and you keep overhaul every one of us

rice purity test quiz

Grace Ella said...

Thanks for sharing unique information with us. Getting proper information about the return of code access security was very difficult for me and I was looking for accurate information to solve my problem. After following your instructions, I have solved my issue. Dissertation Writing Services

whatsaap Plus said...

download the whatsapp Plus in your android phone from the
simply clicking on the link