Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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=1.0.0.0, 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

6 Answers 6

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
2  
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);
asm.FullName.ToString()

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

Thanks,

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
1  
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. http://faisalrafique.wordpress.com/2013/01/16/how-to-determine-an-assemblys-fully-qualified-name/

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

 
discard

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.