SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I opened an empty sharepoint project in which I added a new application page. There I wrote some code. Now I need to enter that information under <SafeControls> tag in web.config file.

SafeControl Assembly="SharePointProject2, Version=, Culture=neutral, PublicKeyToken=PublicKeyToken" Namespace="NamespaceOfYourProject" TypeName="*" Safe="True" />

So please suggest me how to find the PublicKeyToken for my application page.

Thanks & Regards,
Chandra Shekhar

share|improve this question

You can use the sn tool to find the PublicKeyToken for your application. Simply build the assembly and use sn -T <assembly name>

If you are using SharePoint 2010 tooling you could also use $SharePoint.Project.AssemblyFullName$ In your code to insert the current assembly name at build time

share|improve this answer
Hello Tim. Thank u for the suggestion. So I need to navigate to Visual studio command prompt 2010 and type the above mentioned command right? So I should type sn-T myprojectname.dll. Is it right??? And I also dont understand "build the assembly" how to do that??? – Chandra Shekhar Jun 7 '11 at 10:59
Just command prompt should do - but the location of sn (which differs per machine) must be in the path. – Tim Ebenezer Jun 7 '11 at 11:00
So I should navigate to bin folder? – Chandra Shekhar Jun 7 '11 at 11:01
Hello, I found the solution for my answer. When you navigate to assembly folder there you will find .dll files just right click in the appropriate .dll file-> properties and there you can find the PublicKeyToken. Thanks – Chandra Shekhar Jun 7 '11 at 11:12
The $SharePoint.Project.AssemblyFullName$ answer from Tim is working very well too! No need to search for PuplicKeyToken – Gabriel Mongeon Jun 8 '11 at 20:46

If you want to do it directly in Visual Studio, follow this guide to set up the sn external tool.

share|improve this answer

You can get fully qualified name using below code.

Assembly asm = Assembly.LoadFrom(FileName);

I have created utility for this. You can find it here.


Ashish Chotalia

share|improve this answer

For information, you don't have to add a "safecontrol" entry in the web.config file if you use the standard SharePoint solution package (WSP) to deploy your page :

"safecontrol" entries will be automatically added by SharePoint when deploying the WSP.

share|improve this answer
Depending on your level of masochism, you will normally need to enter the SafeControls element into your manifest.xml which will be built into the solution. If you want to avoid said masochism, a tool like WSPBuilder will generate this for you. – James Love Jun 7 '11 at 21:52

An alternative solution, if your project is deployed to the server, is to use

gacutil /l SharePointProject2

From, for instance, the Visual Studio command prompt. You can then cut and paste the Public Key Token from the command window using the Mark tool. This prints the information about the assembly from the Global Assembly Cache.

share|improve this answer
Or you can go to the C:\Windows\assembly folder and copy the public key token from there. – Mihai Jun 7 '11 at 19:11

You can follow the blog here.

share|improve this answer
Welcome to SharePoint! While this may answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Kit Menke Jan 16 '13 at 21:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.