Condividi tramite


How to: Troubleshoot VSPackages

Following are common problems that you might experience with your VSPackage and tips to resolve the issues.

To troubleshoot a VSPackage that keeps Visual Studio from starting

  • Start Visual Studio in safe mode. During this process all VSPackages are omitted except the VSPackages that are included with Visual Studio.

    To start Visual Studio in safe mode, at a command prompt, type devenv.exe /safemode.

To troubleshoot a VSPackage that does not load

  1. Make sure that you are using the registry root in which the VSPackage is registered to run, usually the experimental registry root.

    For more information, see Experimental Instance of Visual Studio.

  2. If the VSPackage is targeted to run in the experimental registry root, make sure that you are running the experimental version of Visual Studio.

    To run the experimental version, type the following at the Visual Studio Command Prompt: devenv /rootsuffix exp.

  3. Check your VSPackage registry entries.

    For more information, see Registering VSPackages and Loading VSPackages.

  4. Open the Output window of the instance of Visual Studio that is failing to load the VSPackage. Information about why the VSPackage is failing to load may be displayed in that window.

    Nota

    If you are starting the experimental version of Visual Studio from the Visual Studio integrated development environment (IDE), inspect the Output window of both versions.

  5. For more information about exceptions thrown by the IDE, click Exceptions on the Debug menu to enable the exceptions. In the Exceptions dialog box select the types of exceptions about which you want more information.

To troubleshoot a VSPackage that does not register

  • Make sure that the VSPackage assembly resides in a trusted location. RegPkg cannot register assemblies in an untrusted or partially trusted location, such as a network share in the default .net security configuration. Although a warning appears whenever a user creates a project in an untrusted location, the "do not show this message again" checkbox can prevent this warning from reoccurring.

To troubleshoot a command that is not visible or that generates an error when you click a command

  1. Merge the new or changed menu commands and those already in the IDE by typing the following at the Visual Studio Command Prompt: devenv /rootsuffix Exp /setup.

  2. Make sure that Visual Studio can find UI.dll for your VSPackage.

    1. Find the CLSID of the VSPackage in the Packages section of the registry:

      HKLM\Software\Microsoft\Visual Studio\<version>\Packages

    2. Verify that the path given by the SatelliteDll subkey is correct.

To troubleshoot a VSPackage that behaves unexpectedly

  1. Set breakpoints in your code.

    Good starting points for debugging are the constructor and the initialization method. You can also set breakpoints in the area you want to evaluate, such as a menu command. To enable breakpoints, you must run under the debugger.

    1. On the Project menu, click Properties.

    2. On the Property Pages dialog box, select the Debug tab.

    3. In the Command line arguments box type the root suffix of the development environment that your VSPackage targets. For example, to select the experimental build, type: /RootSuffix Exp.

    4. On the Debug menu, click Start Debugging or press F5.

      Note   If you are debugging a project, create or load an existing instance of your project now.

  2. Use the activity log.

    Trace VSPackage behavior by writing information to the activity log at key points. This technique is especially useful when you run a VSPackage in a retail environment. For more information, see How to: Write to the Activity Log.

  3. Use public symbols.

    To improve readability while debugging, you can attach symbols to the debugger.

    1. From the Tools/Options menu, navigate to the Debugging/Symbols dialog box.

    2. Add this Symbol file (.pdb) location:

      http://msdl.microsoft.com/download/symbols

    3. To improve performance, specify a symbol cache folder, for example:

      C:\symbols
      

To troubleshoot a missing VSPackage or one of its dependencies

  1. For managed code, make sure that the reference paths are correct.

    1. On the Project menu, click Properties.

    2. Select the References tab in the Property Pages dialog box and make sure all paths are correct. Alternatively, you can use the Object Browser to browse for the referenced objects.

      For managed code, you can use the Fuslogvw.exe (Assembly Binding Log Viewer) to display the details of failed assembly loads.

  2. For unmanaged code, find the CLSID of the VSPackage in the Visual Studio CLSID registry node:

    HKLM\Software\Microsoft\Visual Studio\<version>\CLSID

Make sure that the InprocServer32 entry has the correct path of the VSPackage dll.

See Also

Other Resources

VSPackages