Troubleshooting

Visual Studio Extensibility Cookbook

A collection of solutions to common problems encountered when developing Visual Studio extensions.

Package did not load correctly

This is the most common error when developing extensions. It typically means your package class threw an exception during initialization.

To diagnose:

  1. Check the Activity Log - open it at %AppData%\Microsoft\VisualStudio\<version>\ActivityLog.xml or launch VS with:

     devenv.exe /Log
    
  2. Look for your package name in the log to find the exception details.

Common causes:

Extension doesn’t appear after building

Reset the Experimental Instance

The Experimental Instance stores extension installations separately from your main VS. If it gets corrupted, reset it:

devenv.exe /ResetSettings /rootsuffix Exp

Or use the Reset the Visual Studio Experimental Instance shortcut in the Start Menu (installed with the VS SDK workload).

Alternatively, delete the folder manually:

%LocalAppData%\Microsoft\VisualStudio\<version>Exp

Command doesn’t show up in menus

Threading errors

Visual Studio has strict threading rules. Most VS services must be accessed on the UI thread.

Symptoms:

Solutions:

MEF component not found

If your MEF-exported component isn’t being picked up:

Debugging tips

Attach to the Experimental Instance

When you press F5, Visual Studio launches the Experimental Instance with the debugger attached. If you need to attach manually:

  1. Launch the Experimental Instance: devenv.exe /rootsuffix Exp
  2. In your development VS instance, use Debug -> Attach to Process and select the devenv.exe process.

Use the Activity Log

Write to the VS Activity Log for diagnostic purposes:

IVsActivityLog log = await VS.Services.GetActivityLogAsync();
log.LogEntry(
    (uint)__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION,
    "MyExtension",
    "Extension loaded successfully");

View the log at %AppData%\Microsoft\VisualStudio\<version>\ActivityLog.xml.

Output Window logging

Write diagnostic messages to a custom Output Window pane:

OutputWindowPane pane = await VS.Windows.CreateOutputWindowPaneAsync("My Extension");
await pane.WriteLineAsync("Diagnostic: command executed");

Build errors after updating packages

After updating NuGet packages, you may see build errors related to missing types or ambiguous references:

Extension works in Experimental but not after install

Additional resources

Last updated: