This documentation is archived and is not being maintained.

Automating the Deployment of Outlook Add-Ins by using Visual Studio Tools for Office Second Edition

Office 2007

Summary: Learn how to automate the deployment of Microsoft Outlook add-ins to any number of client machines by using Visual Studio 2005 Tools for Office Second Edition.(18 printed pages)

Albert Raiani, Senior Software Developer, twentysix New York

January 2008

Applies to: Microsoft Office Outlook 2007, Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System (also known as "Visual Studio 2005 Tools for Office Second Edition"), Microsoft Office Outlook 2003


The Visual Studio Tools for Office 2005 Second Edition (VSTO 2005 SE) Office Add-In project templates in Microsoft Visual Studio 2005 add a setup project preconfigured to install your add-in on a user's machine. In most cases, all you need to do is build the project and run the installer on the client machine. This is suitable when you have a small number of clients to support. However, this is tedious when you must distribute your application companywide to tens, hundreds, or even thousands of users. From my experience, an application is never just installed and forgotten about. Often times, new releases are published monthly, weekly, or even daily. Also, if you want to ensure that your clients are always running the most current version of the project without relying on someone to physically install the project, then you need to have a more automatic way of distributing new versions. You could build your own mechanism or, better yet, take advantage of the Publish Wizard that comes with Visual Studio 2005.

Until Microsoft Visual Studio 2008 is released, Click Once deployment is not available for Office 2003 and Office 2007 add-ins created with VST0 2005 SE. However you can still take advantage of the Publish Wizard in order to make automatic updates to an application. The main reason that you cannot deploy projects by using Click Once technology is that, for Microsoft Office add-ins, registry settings must be added to the Windows Registry. However, after you install the application by using the installer created in VSTO 2005 SE, the necessary settings are added to the registry and you can then make use of the Publish Wizard for subsequent updates.

This article walks you through the process of creating an Outlook add-in, deploying it to a client machine, ensuring that the prerequisites are satisfied, and then updating the application using the Publish Wizard. This ensures that the clients of your add-in get the most current code automatically.

To load and run a VSTO 2005 SE add-in on the client machine, you must already have the following components installed.

  • The .NET Framework 2.0

  • The VSTO 2005 SE Runtime

  • The Primary Interop Assemblies (PIAs)

By default, VSTO 2005 SE add-ins do not have the level of trust required to run a project. You must create .NET Framework's Code Access Security (CAS) feature policies that allow the project to run.

These policies specify the minimum requirements that allow VSTO 2005 SE add-ins to run. If you are deploying to different locales, you must also install the VSTO 2005 SE language pack for the regions. For more information, refer to Deploying Visual Studio 2005 Tools for the Office System SE Solutions Using Windows Installer (Part 1 of 2).

Installing the .NET Framework 2.0 Runtime

For the purposes of this article, it is assumed that the .NET Framework 2.0 is already installed. However, you can download and install the .NET Framework 2.0.

Installing the VSTO 2005 SE Runtime

It is important that you make sure you are running the latest version of the VSTO Runtime. To check which version of the runtime you have installed, look for the registry setting HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSTO Runtime Setup\v2.0.5.0727 and make sure that the Update setting is set to either 1 or 2. If there is no update setting or you cannot find this key then either you have an earlier version or the runtime is not installed. Download and install the Visual Studio 2005 Tools for Office Second Edition Runtime (VSTO 2005 SE).


The same version of the VSTO 2005 SE Runtime is installed for both Office 2003 and Office 2007.

Installing the Microsoft Office PIAs

Since Microsoft Office is COM-based, Microsoft provides the PIAs for each Office application as a way for unmanaged code to be called by .NET managed code.

The easiest way to determine if the Microsoft Office PIAs are installed is to examine the Global Assembly Cache (GAC). The GAC is located by default at: C:\Windows\Assembly\. If the PIAs are installed, your GAC looks similar to the following figure.

Figure 1. The Microsoft Office PIAs are installed in the GAC

Office PIAs installed in GAC

For Office 2003, version is installed and for Office 2007, version is installed.

Download the Office 2003 Update: Redistributable Primary Interop Assemblies.

Download the 2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies.

To ensure that these prerequisites are installed on your client's machines when you install your application, add launch conditions to your project that check for the PIAs and the VSTO 2005 SE runtime. For more information, refer to Deploying Visual Studio 2005 Tools for the Office System SE Solutions Using Windows Installer (Part 1 of 2).

Creating the Code Access Security Policies

By default all VSTO Office add-ins are untrusted. When you run your application from Visual Studio, there is no need to grant permissions for your add-in to run because Visual Studio adds the necessary permissions for you when you build your project. You can see this in the Visual Studio 2.0 Configuration Management Console after you build your add-in.

To view the CAS policy that Visual Studio creates, in Control Panel, double-click Administrative Tools, and then double-click the Microsoft Framework 2.0 Configuration tool. In the .NET Framework 2.0 Configuration dialog box, navigate to \My Computer\Runtime Security Policy\User\Code Groups\All_Code\VSTOProjects and click the node for your project to see the policies that Visual Studio created (see Figure 2).

Figure 2. VSTO Projects security group in the .NET Framework 2.0 Configuration dialog box

VSTO Projects security group

Visual Studio uses the location of the compiled .dll files as the evidence of the membership conditions for specific permissions. For example, if you build and run the project in a debug configuration, you see a debug subgroup and a path similar to C:\<projects folder>\MyOutlookAddIn\bin\debug\MyOutlookAddIn.dll in the URL property of the membership condition.

When you install your project on a client machine, however, you need to explicitly grant these permissions. You can write a script to execute Caspol.exe which is shown here. Later in this article, you will see how to create a custom action and add it to your setup project.


The .NET Framework 2.0 Management Console Snap-In is only available if you install the .NET Framework 2.0 Software Development Kit (SDK). Without the .NET Framework 2.0 Management Console Snap-In, you must use the command line tool Caspol.exe to create the policy on the client machine.

You can find Caspol.exe on your client machine where the .NET Framework is installed. The default location is C:\Program Files\Microsoft.NET\Framework\v2.0.50727.

You need to add a policy that grants full trust to the location where the assembly is installed. Assuming that the project is installed to C:\Program Files\MyOutlookAddIn, run the following command.

Caspol –m –ag My_Computer_Zone –url "C:\Program Files\MyOutlookAddIn\*" FullTrust –n My_Outlook_AddIn_URL_Policy

Assuming that you are loading the application from a server, you need to trust the deployment location. At this point, you need to know the location where you publish to. For this example, assume that you have a network share named "Publish" on a server named "AppServer". Run the following command from a command prompt.

Caspol –m –ag My_Local_Intranet_Zone –url "\\AppServer\Publish\*" FullTrust –n My_Outlook_AddIn_PublishLocation_Policy

This command tells the .NET Framework to trust everything contained in that URL.

It is good practice to remove these policies when you uninstall your application. You need to run these commands to remove the policies.

Caspol –m –rg My_Outlook_AddIn_URL_Policy

And then run this command.

Caspol –m –rg My_Outlook_AddIn_PublishLocation_Policy


If you find yourself creating many policies for many assemblies, consider signing your assemblies with a Strong Name and then creating a security policy that uses a Strong Name membership condition. For more information, refer to How to: Sign an Assembly with a Strong Name. For more information on Strong Name member conditions, refer to How to: Add Code Groups Using Caspol.exe.

To automate creating the security policies by adding Custom Actions to your setup project, refer to the "Enhancing The Outlook Add-In Setup Project" section of the document Deploying Visual Studio 2005 Tools for Office Solutions Using Windows Installer: Walkthroughs (Part 2 of 2).

The add-in adds a new command bar and button to Outlook. When clicked, the button invokes code to mark all items in the "Deleted Items" folder as read. After the operation is complete, the user is notified.

To create new Office 2003 or 2007 add-in project

  1. Start Visual Studio. On the File menu, click New, and then click Project.

  2. In the left-pane of the New Project dialog box (see Figure 3), click Visual Basic, Office, 2007 Add-in (or 2003 Add-in), and click Outlook Add-In.

    Figure 3. The New Project dialog box

    New Project dialog box
  3. Type the Name as MyOutlookAddIn.

  4. Type the Solution Name as AutoDeployOutlookAddIn.

  5. Click OK

  6. In Solution Explorer, double-click to open the ThisAddin.vb file and type or paste the following code.

    public class ThisAddIn
       Dim explorer As Outlook.Explorer = Nothing
       Private Sub ThisAddIn_Startup(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Me.Startup
          explorer = Me.Application.ActiveExplorer
          Dim myBar As Office.CommandBar = _
    explorer.CommandBars.Add(Name:="MyCustomCommandBar", _
    Position:=Office.MsoBarPosition.msoBarTop, _
          Dim myButton As Office.CommandBarButton = _
    CType(myBar.Controls.Add( _
    Type:=Office.MsoControlType.msoControlButton), _
          myButton.Caption = "Mark Deleted Items as Read"
          myBar.Visible = True
          myButton.Visible = True
          AddHandler myButton.Click, AddressOf Me.MyButton_Click
       End Sub
       Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
          ByVal e As System.EventArgs) Handles Me.Shutdown
       End Sub
       Protected Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, ByRef CancelDefault As Boolean)
          Dim ns As Outlook.NameSpace = Application.GetNamespace("MAPI")
          Dim deletedItems As Outlook.MAPIFolder = _
          Dim unreadItems As Outlook.Items = _
             deletedItems.Items.Restrict("[Unread] = true")
          Dim unreadItemCount As Integer = unreadItems.Count
          For Each item As Object In unreadItems
             If TypeOf item Is Outlook.MailItem Then
                 CType(item, Outlook.MailItem).UnRead = False
             ElseIf TypeOf item Is Outlook.ContactItem Then
                 CType(item, Outlook.ContactItem).UnRead = False
             ElseIf TypeOf item Is Outlook.AppointmentItem Then
                 CType(item, Outlook.AppointmentItem).UnRead = False
             ElseIf TypeOf item Is Outlook.TaskItem Then
                 CType(item, Outlook.TaskItem).UnRead = False
             ElseIf TypeOf item Is Outlook.MeetingItem Then
                 CType(item, Outlook.MeetingItem).UnRead = False
             ElseIf TypeOf item Is Outlook.DocumentItem Then
                 CType(item, Outlook.DocumentItem).UnRead = False
             ElseIf TypeOf item Is Outlook.PostItem Then
                 CType(item, Outlook.PostItem).UnRead = False
                 ' Skip this one if it doesn't have an UnRead property.
                 unreadItemCount -= 1
             End If
          Dim message As String = String.Format("{0} items were marked as read", unreadItemCount)
          MessageBox.Show(message, "My Outlook Add-In", MessageBoxButtons.OK, _
       End Sub
    End class
  7. Build and run the add-in by clicking the Debug menu and then clicking Start Debugging. When the project loads, Outlook starts and you see a new command bar and button with the text Mark Deleted Items as Read (see Figure 4).

    Figure 4. Outlook displays the new command bar and button

    New command bar and button

    Notice the number of items in the deleted items folder. When you click the button, all unread items are marked as read as shown in Figure 5.

    Figure 5. All unread items are set to read

    Unread items set to read

For this example, you publish the add-in to a network file share named "\\AppServer\Publish", but you can just as easily publish to an IIS web server.

To configure the Publish Wizard

  1. Switch to Release configuration by selecting Release in the configuration dropdown box on the standard toolbar in Visual Studio as shown in Figure 6. This step is very important; otherwise, the automatic updates may not work correctly.

    Figure 6. Select Release in the configuration dropdown box

    Select Release
  2. In Solution Explorer, right-click the MyOutlookAddIn project and select Properties. In the Properties dialog box, click the Publish tab as shown in Figure 7.

    Figure 7. The Publish tab in the Properties pane

    Publish tab
  3. Set the publish location to \\AppServer\Publish\ and the version number to, respectively. You can set the Version automatically to increment; however, during testing it is easier to manually increment it, if desired.

  4. Click Publish Now. Visual Studio builds the add-in in the Release configuration and publishes it to "\\AppsServer\Publish". If you examine the publishing location in Windows Explorer, you see an application manifest named MyOutlookAddIn.application and a new directory named MyOutlookAddIn_1.0.0.0.

You published the application before building the setup project so that Visual Studio includes the correct assembly manifest file in the project. If you look at the manifest file that Visual Studio generates in the directory <projects>\bin\release\MyOutlookAddIn.dll.manifest, it does not contain the correct publish location. For this reason you need to use the manifest file generated when the application was published. You can find this file in <projects>\bin\release\publish\MyOutlookAddIn.Publish\MyOutlookAddIn_1.0.0.0. Therefore you must include this file in the setup project instead.

To configure and build the project

  1. Use an exclude filter to filter out the incorrect manifest file. In Solution Explorer, right-click Primary output from MyOutlookAddIn (Active) and select Exclude Filters. Add a filter for "*.manifest" (see Figure 8).

    Figure 8. Set the filter type to exclude the incorrect manifest file

    Set filter type
  2. Add the correct manifest file to the setup project.

    1. Right click the MyOutlookAddInSetup project, point to Add, and then click File.

    2. Navigate to the correct manifest file and select it. For example, navigate to C:\<projects folder>\AutoDeployOutlookAddIn\MyOutlookAddIn\bin\release\MyOutlookAddIn.publish\MyOutlookAddIn_1.0.0.0\MyOutlookAddIn.dll.manifest. Remember to change this every time that you publish with a new version number.

  3. With MyOutlookAddInSetup selected in Solution Explorer, in the Properties window, change the following settings

    1. Set InstallAllUsers to TRUE. It is important to note that this setting does not actually install the add-in for use by all users. By default the add-in is loaded in Outlook only for the user that installed it. This is because of how the .msi registers the add-in. Later in this article, you will see how to change these settings to make the add-in available to all users on the machine.

    2. Set the Version Number to the product’s version number. This is the number displayed in Add Remove Programs (Programs and Features in Microsoft Windows Vista) in Control Panel. When you set this value, Visual Studio prompts you to regenerate the product code. If you have the DetectNewerInstalledVersion and RemovePreviousVersion properties set to TRUE then choose YES.

    3. Type your company name in the Manufacturer property. When the setup runs, the default installation path includes this value. For example, if 26ny is entered then the path defaults to C:\Program Files\26ny\MyOutlookAddIn.

  4. Right click the MyOutlookAddInSetup project in Solution Explorer and choose Build from the context menu. If in your assembly information file the AssemblyVersionAttribute option is set to generate version numbers automatically, you may want to avoid automatically generating a new version number when you build the setup project. You can prevent a new version number from being generated by deselecting the option in Configuration Manager.

    1. In Visual Studio, click the Build menu and click Configuration Manager (see Figure 9).

    2. Make sure that Release configuration is selected

    3. Clear the MyOutlookAddIn project so that it does not build.

    4. Close the Configuration Manager.

    Figure 9. The Configuration Manager dialog box

    Configuration Manager

After the setup project is built, the MyOutlookAddIn.msi file is contained in the Bin folder of the MyOutlookAddInSetup project. The path should be similar to C:\<projects folder>\AutoDeployOutlookAddIn\MyOutlookAddInSetup\Release. Make sure that Outlook is closed on the client machine.

To install and test the add-in

  1. Locate the setup project, copy it to your client’s machine, and execute it to install the add-in.

  2. Start Microsoft Outlook. If you do not see the Mark Deleted Items as Read button, there are tips for debugging the project at the end of this article.

  3. Make a change, and then rebuild and republish the add-in project.

Next make a code change and republish the application.

To modify and republish the project

  1. In Solution Explorer, open the file ThisAddIn.vb and change the line that reads myButton.Caption = "Mark Deleted Items as Read" to myButton.Caption = "Mark All Deleted Items Read".

  2. In the Configuration Manager, ensure that MyOutlookAddIn is selected to build in Release configuration. This setting was switched off in a previous step.

  3. In Solution Explorer, click the MyOutlookAddIn project, right-click, and click Properties to open the properties window and click Publish.

  4. In the Publish tab, increment the version’s revision number to

  5. Click Publish Now.

Typically, you want your add-in available to all users on the client machine. Accomplishing this is slightly different for Office 2003 than Office 2007. In either case, you must modify or create the necessary registry entries.

For Outlook 2003, it is a simple matter of creating the appropriate registry entries in the HKEY_LOCAL_MACHINE hive in the Windows registry instead of the HKEY_CURRENT_USER hive. The MyOutlookAddInSetup project that Visual Studio generates already creates the registry entries that you need. All you need to do is move the settings from HKEY_CURRENT_USER to HKEY_LOCAL_MACHINE.

To install for all users in Office 2003

  1. In Solution Explorer, right-click the MyOutlookAddInSetup project, point to View, and click Registry.

  2. In Registry On Target Machine, expand the HKEY_CURRENT_USER folder and to see a Software folder containing a Classes sub-key and a Microsoft sub-key (see Figure 10).

    Figure 10. The completed Registry on Target Machine setting for Office 2003

    Completed Registry for Office 2003
  3. With the Software folder selected, right-click, and click Cut from the context menu.

  4. Select the HKEY_LOCAL_MACHINE folder, right-click and click Paste.

For Office 2007, managed add-ins must be registered under HKEY_CURRENT_USER. If you were to move the setting to HKEY_LOCAL_MACHINE, the settings are ignored. Therefore, you can take advantage of the HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER propagation mechanism. For this to work, first, you need to create a registry entry in the HKEY_LOCAL_MACHINE hive that instructs Microsoft Office to create the correct setting in the HKEY_CURRENT_USER hive when it launches. Second, you must create a Count registry entry and manage its value using a custom action. It is important to note here that the Count entry must exist and be incremented on installing and uninstalling the add-in, otherwise, the propagation mechanism is not triggered.

To install for all users for Office 2007

  1. In Solution Explorer, right-click the setup project, point to View, and then click Registry.

  2. With Registry on Target Machine open, right click the HKEY_LOCAL_MACHINE folder, click New Key and type the name Software.

  3. Continue and finish creating the following key structure HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\MyOutlookAddIn\Create\Software\Microsoft\Office.

  4. Expand the keys under HKEY_CURRENT_USER, navigate to the key named Outlook, and cut and paste it into the Office folder created above. Now Registry on Target Machine should look like Figure 11.

    Figure 11. The completed Registry on Target Machine setting for Office 2007

    Completed Registry for Office 2007

You cannot create the Count registry entry the same way as the others because it's value must be incremented for every install and uninstall. A Custom Action can be used to accomplish this.

To create a custom action to manage count and clean-up

  1. In Solution Explorer, right-click the solution, point to Add, and then click New Project.

  2. In the Add New Project dialog box, expand Other Languages, click Visual Basic, select Class Library, type the name MyOutlookAddInCustomAction, and click OK.

  3. Delete the Class1.vb file that is automatically created for the project.

  4. Right-click the new project, point to Add, and then click New Item.

  5. In the Add New Item dialog box, select Installer Class, type the name MyInstallerActions.vb, and click Add.

  6. With MyInstallerActions.vb selected, press F7 on your keyboard to open the code view.

  7. Type the following code in MyInstallerActions.vb code window.

    Imports System.ComponentModel
    Imports System.Configuration.Install
    Imports Microsoft.Win32
    Public Class MyInstallerActions
       Dim _appRegKeyPath As String = _ 
    "Software\Microsoft\Office\12.0\User Settings\MyOutlookAddIn"
       Public Sub New()
          ' This call is required by the Component Designer.
            ' Add initialization code after the call to InitializeComponent.
       End Sub
       Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
       End Sub
       Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
       End Sub
       Private Sub IncrementCount()
          Dim appKey As RegistryKey = _
    My.Computer.Registry.LocalMachine.OpenSubKey( _
    Me._appRegKeyPath, True)
          Dim count As Object = appKey.GetValue("Count")
          If count Is Nothing Then
             appKey.SetValue("Count", 1)
             appKey.SetValue("Count", Convert.ToInt32(count) + 1)
          End If
       End Sub
       Private Sub RemoveDeleteInstruction()
          Dim appKey As RegistryKey = _
    My.Computer.Registry.LocalMachine.OpenSubKey( _
    Me._appRegKeyPath, True)
          Dim deleteKey As RegistryKey = _
    appKey.OpenSubKey("DELETE", False)
          If deleteKey IsNot Nothing Then
          End If
       End Sub
       Private Sub RegisterDeleteInstruction()
          Dim appKey As RegistryKey = _
    My.Computer.Registry.LocalMachine.OpenSubKey( _
    Me._appRegKeyPath, True)
          appKey.CreateSubKey( _
       End Sub
    End Class
  8. In Solution Explorer, right-click MyOutlookAddInSetup, point to View, and click Custom Actions.

  9. In the Custom Actions dialog box, right-click the Custom Actions node and then click Add Custom Action.

  10. In the Select Item in Project dialog box, click the Look in dropdown and then click Application Folder.

  11. On the right-side of the dialog box, click the Add Output button. This displays the Add Project Output Group dialog box.

  12. Click the Project dropdown and select MyOutlookAddInCustomAction.

  13. Click Primary Output and then click OK twice. The Custom Actions window looks like Figure 12.

  14. Click OK to close the dialog box and add the custom actions.

    Figure 12. The Custom Actions dialog box

    Custom Actions
  15. Right-click the MyOutlookAddInSetup project and choose Build.

For more detailed information on how HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER works refer to Misha Shneerson’s MSDN blog posts:

Deploying your VSTO Add-in to All Users (Part 1 of 2)

Deploying your VSTO Add-in to All Users (Part 2 of 2)

You can also use Custom Actions to make creating the code access security policy easier. To do this, you need to modify the Custom Action that you just created by modifying the code.

To modify the custom actions

  1. Add the SetCASPolicy method.

    Private Sub SetCASPolicy(ByVal args As String)
       Dim frameworkPath As String = _ 
       Dim processInfo As New System.Diagnostics.ProcessStartInfo()
       With processInfo
          .FileName = System.IO.Path.Combine( _
    frameworkPath, "caspol.exe")
          .Arguments = args
          .CreateNoWindow = False
          .WorkingDirectory = frameworkPath
          .RedirectStandardError = True
          .RedirectStandardOutput = True
          .UseShellExecute = False
       End With
       Dim process As Process = process.Start(processInfo)
    End Sub
  2. Next, modify the Install procedure.

    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
       ' Grant FullTrust to deployment location.
       Dim targetDirectory As String = _
       Dim dirArgs As String = String.Format _
    ("–m –ag My_Computer_Zone –url ""{0}\*"" FullTrust –n My_Outlook_AddIn_URL_Policy", _
       ' Grant FullTrust to publish location.
       Dim targetURL As String = Convert.ToString(Context.Parameters("targetURL"))
       Dim urlArgs As String = String.Format( _
    "–m –ag My_Local_Intranet_Zone –url ""{0}\*"" FullTrust –n My_Outlook_AddIn_PublishLocation_Policy", targetURL)
       ' Increment the count in registry. This is necessary for HKLM-to-HKCU propagation to work.
    End Sub
  3. Modify the Uninstall procedure.

    Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
       ' Remove CAS policies created during setup.
          Me.SetCASPolicy("–m –rg My_Outlook_AddIn_URL_Policy")
          Me.SetCASPolicy("–m –rg My_Outlook_AddIn_PublishLocation_Policy")
          ' Do nothing if they do not exist.
       End Try
    End Sub
  4. Override the RollBack procedure.

    Public Overrides Sub Rollback(ByVal savedState As System.Collections.IDictionary)
       ' Remove CAS policies if they were created during setup.
          Me.SetCASPolicy("–m –rg My_Outlook_AddIn_URL_Policy")
          Me.SetCASPolicy("–m –rg My_Outlook_AddIn_PublishLocation_Policy")
          ' Do nothing if they do not exist.
       End Try
    End Sub

If your add-in does not load when it should, you can debug it by setting the environment variables VSTO_SUPPRESSDISPLAYALERTS to 0 or VSTO_LOGALERTS to 1. VSTO_SUPPRESSDISPLAYALERTS hides or displays dialog boxes when exceptions occur and VSTO_LOGALERTS creates a log file in the same directory as the executing assembly, if an error occurs.

For more information, see Debugging Application-Level Projects.