Microsoft KB Archive/823997

= How to create a strong-named Visual Studio Tools for the Office System 2003 assembly and then register the assembly in the global assembly cache =

Article ID: 823997

Article Last Modified on 2/3/2006

-

APPLIES TO


 * Microsoft Visual Studio Tools for the Microsoft Office System version 2003

-





IN THIS TASK

 * SUMMARY
 * MORE INFORMATION
 * Create the signature key file for the assembly
 * Create the assembly
 * Register the assembly in the global assembly cache
 * Trust the strong-named assembly



SUMMARY
This article describes how to create a strong-named Microsoft Visual Studio Tools for the Microsoft Office System 2003 assembly, how to register the assembly in the global assembly cache, and how to configure the Microsoft .NET Runtime Security Policy to trust the strong-named assembly.

back to the top



Create the signature key file for the assembly
 Click Start, point to All Programs, point to Microsoft Visual Studio .NET 2003, click Visual Studio .NET Tools, and then click Visual Studio .NET 2003 Command Prompt. At the Visual Studio .NET 2003 command prompt, type the following command to create a signature key file for the assembly:

sn -k c:\word.snk



back to the top

Create the assembly
 Start Visual Studio .NET 2003. On the File menu, click New, and then click Project. In the New Project dialog box, click Microsoft Office System Projects under Project Types, and then click Visual Basic Projects.</li> Under Templates, click Word Document.</li> In the Name box, type StrongNameProject, and then click OK.</li> In the Microsoft Office Project Wizard dialog box, click Create a new document, and then click Finish.</li>  In the ThisDocument.vb file, change the following code: ' Called when the document is opened. Private Sub ThisDocument_Open Handles ThisDocument.Open

End Sub Change this code to the following code: ' Called when the document is opened. Private Sub ThisDocument_Open Handles ThisDocument.Open MsgBox(&quot;Document Open event fired&quot;) End Sub </li> In Solution Explorer, double-click AssemblyInfo.vb.</li>  Add the following code to the bottom of the AssemblyInfo.vb file: <Assembly: AssemblyKeyFile(&quot;C:\word.snk&quot;)> </li> On the Build menu, click Build Solution.</li></ol>

back to the top

Register the assembly in the global assembly cache
 Click Start, point to All Programs, point to Microsoft Visual Studio .NET 2003, click Visual Studio .NET Tools, and then click Visual Studio .NET 2003 Command Prompt.</li> At the Visual Studio .NET 2003 Command Prompt, locate the folder that contains the StrongNameProject assembly, and then run the following command to register the assembly in the global assembly cache:

gacutil /i StrongNameProject.dll

You receive the following message in the command prompt window:

Assembly successfully added to the cache.

</li></ol>

back to the top

Trust the strong-named assembly

 * 1) In Control Panel, click Administrative Tools.
 * 2) Double-click Microsoft .NET Framework 1.1 Configuration.

Note There may be several similar tools that have names that start with Microsoft .NET Framework. Make sure that the configuration tool that you use matches your version of the runtime environment.
 * 1) In the left pane, expand Runtime Security Policy, expand User, expand Code Groups, expand All_Code, and then click Office_Projects.

Note If you have never compiled a Microsoft Office Word 2003 project or a Microsoft Office Excel 2003 project, you do not have the Office_Projects folder on your computer. You can add the new code group to the All_Code root node, or you can compile an Office 2003 project to automatically create the Office_Projects folder.
 * 1) The Office_Projects Code Group description on the right has a Tasks section at the bottom of the page.

In the Tasks section, click Add a Child Code Group.

The Create Code Group Wizard starts.
 * 1) Click Create a new code group, and then type a name and a description to help you identify the project. Click Next.
 * 2) In the Choose the condition type for this code group list box, click Strong Name.
 * 3) Click Import to locate the strong name and to retrieve the strong name from the StrongNameProject.dll assembly. Click Next.
 * 4) Click Use existing permission set, and then click FullTrust. Click Next.
 * 5) Click Finish.
 * 6) Open the StrongNameProject.doc file.

The message box for the ThisDocument_Open event appears.

back to the top

Keywords: kbhowto KB823997

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.