Everything SharePoint and XAML

My continuous learning of SharePoint, XAML, Silverlight, Windows Phone 7, Windows 8, Office, VSTO, C#…

Part 3: Create Strong Name Assembly

Posted by Steve Pietrek on June 6, 2007

This is Part 3 of a series on creating web parts and deploying them to SharePoint using a VS 2005 Solution Project. There are 6 parts in the series.

1. Web parts should have a strong name when used in SharePoint.
2. In the HelloWorldWebPart project, open the AssemblyInfo.cs file and add the attribute [assembly: System.Security.AllowPartiallyTrustedCallers()]
3. Right-click on the HelloWorldWebPart project and select Properties
4. Select the Signing option
5. In the drop down list, select the option
6. Type in a Key File Name (e.g. keypair.snk)
7. Uncheck the Protect my key file with a password option
8. Click OK
9. The keypair.snk file will be added to the project
10. The next step is to create a manifest file. The manifest file contains the information to update the web application’s web.config file with the necessary information for your web part.
11. Right-click the HelloWorldWebPart project and select Add-New Item
12. Select the Visual C# Project Items category, select the XML File template, name the file Manifest.xml, and click the Add button
13. In the Properties Window, select the Schemas property, open the toolbox designer, and select the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\wss.xsd schema. This will give Intellisense functionality in the editor.
14. Add the following code:

<?xml version=1.0 encoding=utf-8 ?>

<Solution xmlns=http://schemas.microsoft.com/sharepoint/ SolutionId=BC5D2EC3-583B-4d7a-A96B-28B2BE452259>


<Assembly DeploymentTarget=WebApplication Location=HelloWorldWebPart.dll>


<SafeControl Assembly=HelloWorldWebPart, Version=, Culture=neutral, PublicKeyToken=23cf0824e5fabd76 Namespace=HelloWorld.Web TypeName=*/>





15. Note the DeploymentTarget has two options. You can either deploy to the GAC or the virtual directory’s bin folder.
16. To create the GUID, select Tools-Create GUID, select Option 4, and click the Copy button. Paste the GUID into the SolutionId but delete the opening and closing braces (e.g. { }).
17. To add a menu option for retrieving the project’s Public Key Token, do the following (once it is done you will not need to create the menu item again):

  1. Select Tools-External Tools from the main menu
  2. Click the Add button
  3. Title: Add Get Public Key
  4. Command: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe
  5. Arguments: -Tp “$(TargetPath)”
  6. Uncheck Close on exit
  7. Check Use Output window
  8. Click OK

18. Build HelloWorldWebPart project just to ensure the Public Key can be created properly.
19. Select Tools>Get Public Key
20. Copy the Public Key Token from the Output Window and paste in the manifest.xml file
21. Save the project and rebuild the HelloWorldWebPart project


Sorry, the comment form is closed at this time.

%d bloggers like this: