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 (823997)



The information in this article applies to:

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

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

MORE INFORMATION

Create the signature key file for the assembly

  1. 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.
  2. 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

  1. Start Visual Studio .NET 2003.
  2. On the File menu, click New, and then click Project.
  3. In the New Project dialog box, click Microsoft Office System Projects under Project Types, and then click Visual Basic Projects.
  4. Under Templates, click Word Document.
  5. In the Name box, type StrongNameProject, and then click OK.
  6. In the Microsoft Office Project Wizard dialog box, click Create a new document, and then click Finish.
  7. 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("Document Open event fired")
        End Sub
  8. In Solution Explorer, double-click AssemblyInfo.vb.
  9. Add the following code to the bottom of the AssemblyInfo.vb file:
    <Assembly: AssemblyKeyFile("C:\word.snk")>
  10. On the Build menu, click Build Solution.
back to the top

Register the assembly in the global assembly cache

  1. 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.
  2. 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.
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.
  3. 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.
  4. 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.
  5. Click Create a new code group, and then type a name and a description to help you identify the project. Click Next.
  6. In the Choose the condition type for this code group list box, click Strong Name.
  7. Click Import to locate the strong name and to retrieve the strong name from the StrongNameProject.dll assembly. Click Next.
  8. Click Use existing permission set, and then click FullTrust. Click Next.
  9. Click Finish.
  10. Open the StrongNameProject.doc file.

    The message box for the ThisDocument_Open event appears.
back to the top

Modification Type:MinorLast Reviewed:2/3/2006
Keywords:kbhowto KB823997 kbAudDeveloper