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. 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.
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 method.
To add a solution to the inclusion list
Create a Visual Basic or Visual C# console application or class library that targets the .NET Framework 4.0.
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.
Add a reference to Microsoft.VisualStudio.Tools.Office.Runtime.
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;
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.
Copy the RSAKeyValue element, including all child elements and the RSAKeyValue tags, to the Clipboard.
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("https://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(@"https://DeploymentServer/MySolution/MySolution.vsto"); AddInSecurityEntry entry; try { entry = new AddInSecurityEntry(solutionLocation, publicKey); UserInclusionList.Add(entry); } catch (ArgumentNullException e) { Console.WriteLine("Exception: " + e.Message); }
Build the application.
Run the application on the computer that is running the 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
Create a Visual Basic or Visual C# console application or class library that targets the .NET Framework 4.0.
Add a reference to Microsoft.VisualStudio.Tools.Office.Runtime.
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;
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("https://DeploymentServer/MySolution/MySolution.vsto") Try UserInclusionList.Remove(solutionLocation) Catch e As ArgumentNullException Console.WriteLine(("Exception: " + e.Message)) End Try
Uri solutionLocation = new Uri("https://DeploymentServer/MySolution/MySolution.vsto"); try { UserInclusionList.Remove(solutionLocation); } catch (ArgumentNullException e) { Console.WriteLine("Exception: " + e.Message); }
Build the application.
Run the application on the computer that is running the 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