How to: Add or Remove Inclusion List Entries

The Setup program for Office solutions can add inclusion list entries 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.

Applies to: The information in this topic applies to document-level projects and application-level projects for Microsoft Office 2010 and the 2007 Microsoft Office system. For more information, see Features Available by Office Application and Project Type.

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.

Adding Entries to the Inclusion List

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

To add a solution to the inclusion list

  1. Create a Visual Basic or Visual C# console application or class library that targets the .NET Framework 3.5.

    Note

    If you are deploying an Office solution by using Windows Installer, you can install Office solutions to the Program Files directory and avoid having to create an inclusion list entry.

  2. Add a reference to Microsoft.VisualStudio.Tools.Office.Runtime.v10.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(Uri) method of the UserInclusionList class.

To remove a solution from the inclusion list

  1. Create a Visual Basic or Visual C# console application or class library that targets the .NET Framework 3.5.

  2. Add a reference to Microsoft.VisualStudio.Tools.Office.Runtime.v10.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

Other Resources

Securing Office Solutions