VSTO Add-in Behavior:
Solution:
I am working on VSTO add-in development, recently I faced the above issue and I resolved it. I am going to write as simple Outlook add-in to display “Greetings Veera!” message to the user, when ever user opens Outlook 2007 and the Outlook add-in is available for all users of machine (Machine Level add-in).
Steps to create an Outlook add-in project
2) On the File menu, point to New, and then click Project.
The New Project dialog box appears.
3) Expand the node for the programming language you want to work in
(Visual Basic), and then select the Office node.
The document-level project types appear in the Templates pane.
4) Expand the Office node. There are child nodes for the Office 2003
and Office 2007 add-in project templates.
5) Select the Outlook Add-in template.
6) Accept the default name of Outlook1.
7) Press CTRL+F5 to test the add-in.
In Visual Studio, examine the project. In Project Explorer, you can see that the project wizard created two projects: a project for the add-in itself, and a Setup project. This is consistent with the way traditional “shared” add-in projects are created, as well as Visual Studio 2005 Tools for Office Outlook add-ins.
The project wizard has also added all the necessary references to the .NET, Office, and Visual Studio Tools for Office primary interop assemblies (PIAs), which support the strong-typing that Visual Studio Tools for Office add-ins use.
Finally, notice that Solution Explorer lists only one source file—ThisAddIn.vb. This file provides the standard Visual Studio Tools for Office Startup and Shutdown methods. You can put any initialization code you want into the Startup method, and any termination clean-up code you want into the Shutdown method.
Private Sub ThisAddIn_Startup(ByVal sender As Object,_
ByVal e As System.EventArgs) Handles Me.Startup
MessageBox.Show("Greetings Veera!")
End Sub
2) Press CTRL+F5 to test-run the solution again. This time, when the add-in is loaded
· Select the Signing tab in the Properties pages.
· Select the Sign the assembly check box.
· In the Choose a strong name key file list, click
· Type the name of the Project in the Key file name box.
· Type a password in the Enter password and Confirm password boxes.
· Click OK.
· Close the Properties pages.
· In the Property Pages dialog box, click Prerequisites.
· In the list of prerequisites, select the following items:
a. 2007 Microsoft Office Primary Interop Assemblies
b. Microsoft Visual Studio 2005 Tools for Office SE Runtime
· Select Microsoft Visual Studio 2005 Tools for Office Runtime Language Pack
· Click OK.
Add the SetSecurity Project to our Solution:
2) Delete the default Class1.cs file created.
3) Add a new Installer Class (SetSecurity.vb)
Imports System.ComponentModel
Imports System.Security.Policy
Configure the PolicyLevel and PermissionSet in the code to your needs.
Private ReadOnly installPolicyLevel As String = "Machine"
Private ReadOnly namedPermissionSet As String = "FullTrust"
In the Outlook Setup project, the Primary output from SetSecurity project needs to be included and using the Custom Actions Editor you may add it as a Custom Action for Install and UnInstall as shown below.