简体   繁体   中英

How to debug a Visual Studio Package in a VSIX created in Visual Studio 2015

I'm not able to debug the simplest possible VS Package in the simplest possible VSIX Project.

Steps to reproduce:

  1. Create a VSIX project: File / New / Project / Extensibility / VSIX Project

  2. Add Visual Studio Package: right-click the project node in Solution Explorer and select Add / New Item / Extensibility / Visual Studio Package

  3. Open the newly created package file ( VSPackage1.cs ) and put a breakpoint on line 68, the first line of Initialize() , base.Initialize()

  4. Press F5 to start debugging

This launches an experimental instance of Visual Studio 2015, with the package installed (confirmed in Tools / Extensions and Updates... ), but the breakpoint is disabled:

断点已禁用

The above steps are from the Getting Started guide ( index.html ) of a freshly created VSIX Project, so it should have worked.

Additional info:

  • The solution configuration is Debug , platform is Any CPU
  • The Debug properties of the project automatically have Start external program set to C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe and Command line arguments set to /rootsuffix Exp
  • I set Copy Debug Symbols to Output Directory to True , and after that the projectname.pdb file correctly appeared in bin\\Debug
  • The bin\\Debug\\projectname.vsix file contains projectname.pdb
  • The project is included in Assets in source.extension.vsixmanifest with Type=Microsoft.VisualStudio.VsPackage
  • I tried adding the project in Assets in source.extension.vsixmanifest with Type=Microsoft.VisualStudio.MefComponent but that didn't seem to do much. On the first run after this, the breakpoints appeared enabled, but were not hit. On the 2nd and subsequent runs the breakpoints went back to disabled state during running.
  • I tried changing the version in the manifest, but I notice any effect.
  • I tried running the experimental instance separately, and attaching to it with the debugger, but that behaved the same way as when launching directly with F5 , no difference whatsoever.
  • I tried adding Console.WriteLine statements in the Initialize method, but I couldn't find the debugging texts in the Output window.
  • I tried x86 platform instead of Any CPU, but same result.
  • A colleague followed the same steps and got the same result, so it's probably not specific to my computer. (I invite anyone to please follow the same steps and prove me wrong, or to spot the mistakes in my steps.)

All this seems to suggest that the VS Package is not getting initialized, though it is clearly installed. What am I missing? In case it's relevant, here 's the source code of the VS Package, and here 's the entire dummy project.

If you need more information, please let me know.

VSPackages are loaded into Visual Studio only when their functionality is required. For example, a VSPackage is loaded when Visual Studio uses a project factory or a service that the VSPackage implements. This feature is called delayed loading, which is used whenever possible to improve performance.

To automatially load a package on VS startup, you typically add a ProvideAutoLoad attribute to your main package class.

See Loading VSPackages documentation for more details.

To supplement the other answer here, the solution to the OP's actual problem is:

Just ignore the message and don't worry about it. The symbols aren't loaded right now , but they'll be loaded by the time the breakpoint is ready to be hit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM