Dela via


How to: Add or Remove Inclusion List Entries (2007 System)

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • 2007 Microsoft Office system

For more information, see Features Available by Application and Project Type.

The Setup program for Visual Studio Tools for Office projects can add solutions to the inclusion list when the solution being installed does not have a trusted certificate. The Setup program displays a prompt, and users can respond and indicate that the solution should be trusted. If you want to add your solution to the user's inclusion list without prompting the user, you can programmatically add an inclusion list entry.

For information about inclusion lists, see Trusting Office Solutions by Using Inclusion Lists (2007 System).

The following procedures use console applications to modify the inclusion list. You should avoid modifying the code to accept user input.

link to video For a video version of this topic, see Video How to: Add or Remove Inclusion List Entries (2007 System).

Adding Entries to the Inclusion List

Add AddInSecurityEntry items to the UserInclusionList by using the Add method.

To add a solution to the inclusion list

  1. Create a Visual Basic or Visual C# console application in Visual Studio.

  2. Add a reference to Microsoft.VisualStudio.Tools.Office.Runtime.v9.0.

  3. Open the Module1.vb or Program.cs file for editing and add the following Imports or using statement at the top of the file.

    Imports Microsoft.VisualStudio.Tools.Office.Runtime.Security
    
    using Microsoft.VisualStudio.Tools.Office.Runtime.Security;
    
  4. Open the deployment manifest for the Office solution you are adding to the inclusion list and locate the RSAKeyValue element that appears under the StrongNameSignature node.

  5. Copy the RSAKeyValue element, including all child elements and the RSAKeyValue tags, to the Clipboard.

  6. Add the following code to the Main method, and replace PublicKey with the copied text from the deployment manifest and the sample URI with the location of your deployment manifest.

    Dim publicKey As String = "<RSAKeyValue><Modulus>mUl8MhOil1fKLKYpHItsyCGNXxGJW74L8d4zOVwSvLDP1qoXF0lLqf/Ql8yO+31zuFbx8Aer3eQz9tcb/pz0NJREdbeOvxYa+nHTnR3j7rRUkmE8AKzvcG8BmTlgbprXaY0QTln8syHTC7yY5AA+xibwatFMpEpEBRqF5MmsGkE=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>" 
    Dim solutionLocation As New _
        Uri("http://DeploymentServer/MySolution/MySolution.vsto")
    Dim entry As AddInSecurityEntry
    
    Try
        entry = New AddInSecurityEntry(solutionLocation, publicKey)
        UserInclusionList.Add(entry)
    
    Catch e As ArgumentNullException
        Console.WriteLine(("Exception: " + e.Message))
    End Try
    
    string publicKey = "<RSAKeyValue><Modulus></Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
    Uri solutionLocation = new Uri(@"http://DeploymentServer/MySolution/MySolution.vsto");
    
    AddInSecurityEntry entry;
    
    try
    {
        entry = new AddInSecurityEntry(solutionLocation, publicKey);
        UserInclusionList.Add(entry);
    }
    
    catch (ArgumentNullException e)
    {
        Console.WriteLine("Exception: " + e.Message);
    }
    
  7. Build the application.

  8. Run the application on the computer that is running the Visual Studio Tools for Office solution. The solution with the deployment manifest that is represented by solutionLocation is added to the inclusion list.

Removing Entries from the Inclusion List

Remove entries by using the Remove method of the UserInclusionList class.

To remove a solution from the inclusion list

  1. Create a Visual Basic or Visual C# console application in Visual Studio.

  2. Add a reference to Microsoft.VisualStudio.Tools.Office.Runtime.v9.0.

  3. Open the code file for editing and add the following Imports or using statement at the top of the file.

    Imports Microsoft.VisualStudio.Tools.Office.Runtime.Security
    
    using Microsoft.VisualStudio.Tools.Office.Runtime.Security;
    
  4. Add the following code to the Main method, and replace the sample URI with the location of your deployment manifest.

    Dim solutionLocation As New _
        Uri("http://DeploymentServer/MySolution/MySolution.vsto")
    Try
        UserInclusionList.Remove(solutionLocation)
    
    Catch e As ArgumentNullException
        Console.WriteLine(("Exception: " + e.Message))
    End Try
    
    Uri solutionLocation = new Uri("http://DeploymentServer/MySolution/MySolution.vsto");
    
    try
    {
        UserInclusionList.Remove(solutionLocation);
    }
    
    catch (ArgumentNullException e)
    {
       Console.WriteLine("Exception: " + e.Message);
    }
    
  5. Build the application.

  6. Run the application on the computer that is running the Visual Studio Tools for Office solution. The solution with the deployment manifest that is represented by solutionLocation is removed from the inclusion list.

See Also

Concepts

Trusting Office Solutions by Using Inclusion Lists (2007 System)

Security in Office Solutions (2007 System)