Export (0) Print
Expand All

Improving the Performance of an Application-Level Add-in

You can give your users a better experience by optimizing add-ins that you create for Office applications so that they quickly start up, shut down, open items, and perform other tasks. If your add-in is for Outlook 2013, you can also reduce the chance that your add-in will be disabled because of poor performance. You can increase the performance of your add-in by implementing the following strategies:

For more information about how to optimize an Outlook add-in, see Performance criteria for keeping add-ins enabled.

You can configure an add-in to load only under the following circumstances:

  • The first time that the user starts the application after the add-in is installed.

  • The first time that the user interacts with the add-in after starting the application any subsequent time.

For example, your add-in might populate a worksheet with data when the user chooses a custom button that’s labeled Get My Data. The application must load your add-in at least one time so that the Get My Data button can appear in the ribbon. However, the add-in doesn’t load again when the user starts the application the next time. The add-in loads only when the user chooses the Get My Data button.

To configure a ClickOnce solution to load add-ins on demand

  1. In Solution Explorer, choose the project node.

  2. On the menu bar, choose View, Property Pages.

  3. On the Publish tab, choose the Options button.

  4. In the Publish Options dialog box, choose the Office Settings list item, choose the Load on Demand option, and then choose the OK button.

To configure a Windows Installer solution to load add-ins on demand

To configure a solution to load add-ins on demand while you debug the solution

  1. Create a script that sets the LoadBehavior entry of the Root\Software\Microsoft\Office\ApplicationName\Addins\Add-in ID key to 0x10.

    The following code shows an example of this script.

    [HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\MyAddIn]
    "Description"="MyAddIn"
    "FriendlyName"="MyAddIn"
    "LoadBehavior"=dword:00000010
    "Manifest"="c:\\Temp\\MyAddIn\\bin\\Debug\\MyAddIn.vsto|vstolocal"
    
  2. Create a post-build event that updates the registry by using the script.

    The following code shows an example of a command string that you might add to a post-build event.

    regedit /s "$(SolutionDir)$(SolutionName).reg"
    

    For information about how to create post-build event in a C# project, see How to: Specify Build Events (C#).

    For information about how to create a post-build event in a Visual Basic project, see How to: Specify Build Events (Visual Basic).

If you publish your solution by using Windows Installer, the Visual Studio 2010 Tools for Office Runtime bypasses the following steps when the add-in loads.

  • Validating the manifest schema.

  • Automatically checking for updates.

  • Validating the digital signatures of the deployment manifests.

    Note Note

    This approach isn’t necessary if you deploy your add-in to a secure location on the users’ computers.

For more information, see Deploying an Office Solution by Using Windows Installer.

If you build a solution by using Visual Studio 2012, ensure that your users have installed the most recent version of the Visual Studio 2010 Tools for Office Runtime when you deploy the solution. Older versions of that runtime reflected into solution assemblies to locate ribbon customizations. This process can cause the add-in to load more slowly.

As an alternative, you can prevent any version of the Visual Studio 2010 Tools for Office Runtime from using reflection to identify ribbon customizations. To follow this strategy, override the CreateRibbonExtensibility method, and explicitly return ribbon objects. If your add-in doesn’t contain any ribbon customizations, return null inside of the method.

The following example returns a ribbon object based on the value of a field.

    protected override Microsoft.Office.Core.IRibbonExtensibility
CreateRibbonExtensibilityObject()
    {
        if (myCondition == true)
        {
            return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
                new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { new Ribbon1() });
        }
        else
        {
            return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
                new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { new Ribbon2() });
        }
    }

Consider performing time-consuming tasks (such as long running tasks, database connections, or other sorts of network calls) in a separate thread. For more information, see Threading Support in Office.

Note Note

All code that calls into the Office object model must execute in the main thread.

Show:
© 2014 Microsoft