启动附加到 Outlook 的 VS 2010 调试器来调试插件时遇到困难

发布于 2024-09-08 17:12:12 字数 500 浏览 1 评论 0原文

我正在尝试使用 Visual Studio 2010 和 WPF 用 C# 编写 Outlook 插件,但事实证明它很难调试。我希望 VS 在启动时自动附加到 OUTLOOK.EXE,以便我可以轻松命中断点。所以,我进入了项目的属性>调试选项卡>启动操作并将此设置从“启动项目”(这当然不起作用,因为它是 DLL)更改为“启动外部程序”。

这似乎有效; Outlook 启动,并且显然已附加调试器。但是,没有遇到断点。我注意到,当我进入“附加到进程”对话框时,它说 Outlook 仅运行 x86(我认为这是不正确的,因为我的托管代码正在该地址空间中运行 - 对吗?),因此在“调试”选项卡中在“设置”面板中,我单击“启用非托管代码调试”,但现在我没有主意了。我也无法暂停该进程,因为我收到一条错误,告诉我该进程没有运行我选择调试的代码类型。我知道我的插件肯定已加载并正在执行,因为我可以看到它正在工作。

作为解决方法,我一直在使用 System.Diagnostics.Debugger.Launch(),这很烦人,但它有效。有什么想法吗?

I'm trying to write an Outlook Addin in C# using Visual Studio 2010 and WPF and it's turning out to be difficult to debug. I would like to have VS automatically attach to OUTLOOK.EXE upon startup so that I can hit breakpoints easily. So, I went into the project's properties > Debug tab > Start Action and changed this setting from "Start project" (which of course won't work because it's a DLL) to "Start external program."

This seems to work; Outlook starts and clearly the debugger is attached. However, no breakpoints are hit. I noticed that when I go into the "Attach to Process" dialog it says that Outlook is only running x86 (which I think is incorrect because my manged code is running in that address space -- right?), so in the Debug tab of the Settings panel I clicked "Enable unmanaged code debugging," and now I'm out of ideas. I also can't pause the process because I get an error telling me that the process isn't running the type of code I selected to debug. I know my Addin is definitely loaded and executing because I can see it working.

As a workaround I've been using System.Diagnostics.Debugger.Launch(), which is annoying, but it works. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断爱 2024-09-15 17:12:12

因此,事实证明 Outlook 不会在启动时加载 CLR(必须在必要时立即加载),这显然会混淆 VS 调试器并导致它仅调试本机代码。要强制它立即加载 CLR,请在同一文件夹中创建一个 OUTLOOK.EXE.config 文件:

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50727"/> <!-- or whatever -->
   </startup>
</configuration>

该文件来自 此博文。然后,即使 VS 开始附加,它也会调试 CLR 代码

So it turns out that Outlook doesn't load the CLR on startup (it must be loaded shortly thereafter when it becomes necessary), which apparently confuses the VS debugger and causes it to only debug native code. To force it to load the CLR immediately, create an OUTLOOK.EXE.config file in the same folder with:

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50727"/> <!-- or whatever -->
   </startup>
</configuration>

which is from this blog post. Then, even when VS starts attached, it will debug CLR code

肤浅与狂妄 2024-09-15 17:12:12

以下是如何正确配置 VS 2010 的精彩解释:
链接 < br>
请遵循“在 Visual Studio 2010 中调试针对 CLR 2.0 的加载项”。

Here is excellent explanation how properly configure VS 2010:
Link
follow "Debugging add-ins targeting CLR 2.0 in Visual Studio 2010".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文