如何调试 VSPackage 项目
我安装了 VS2010 SDK 并创建了一个 VSPackage 项目,其中包含一个空的“Initialize”方法。
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[Guid(GuidList.guidGrowl_Extras_VSAddInPkgString)]
public sealed class Growl_Extras_VSAddInPackage : Package
{
public Growl_Extras_VSAddInPackage()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
}
protected override void Initialize()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
base.Initialize();
}
}
如果我在“Initialize”方法中设置断点并在调试模式下运行项目,它将启动实验性 VS 实例,但断点不会命中。它说没有加载调试符号。
我做错了什么?
感谢您的帮助, 恩尼拉
I installed the VS2010 SDK and created a VSPackage project, with an empty "Initialize" method.
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[Guid(GuidList.guidGrowl_Extras_VSAddInPkgString)]
public sealed class Growl_Extras_VSAddInPackage : Package
{
public Growl_Extras_VSAddInPackage()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
}
protected override void Initialize()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
base.Initialize();
}
}
If I set a break point within the "Initialize" method and run the project in debug mode, it starts the experimental VS instance, but the breakpoint does not hit. It says no debug symbols loaded.
What am I doing wrong?
Thanks for help,
Enyra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是完全正常的行为。 Visual Studio 尝试不将您的包加载到内存中,除非确实有必要。 (例如,用户打开了项目类型或执行了包提供处理的命令。)
这种延迟加载是出于性能原因而完成的。如果 VS 在启动时加载了所有扩展和包,那么每次启动 IDE 时您都会等待相当长的时间。
MSDN 上的此页面提供了更详细的说明。
根据您发布的代码片段,您的包没有注册(通过 Provide* 属性)它具有任何功能,因此 Visual Studio 从来没有真正的理由加载它。
This is entirely normal behavior. Visual Studio attempts to not load your package into memory until it absolutely has to. (For example, a user opened a project type or executed a command that your package provides handling for.)
This delay-loading is done for performance reasons. If VS loaded all the extensions and packages at startup, you would be waiting quite a while longer than needed on each start of the IDE.
This page on MSDN explains in further detail.
Based on the code snippet you posted, your package doesn't register (via Provide* attributes) that it has any features, so Visual Studio never has a real reason to load it.