刚刚将我的项目迁移到 Visual Studio 2010,但目标框架仍然是 3.5。项目包含一个部分信任的 XBAP 应用程序和一堆 WCF 服务。
调试配置为使用 -debug 和 -debugSecurityZoneUrl 参数启动 PresentationHost.exe。
在 VS2008 下一切正常,在 VS2010 Beta2(不确定 RC)下,但在 VS2010 下 RTM 调试由于某种原因不起作用。应用程序运行,但没有遇到任何断点。例如,如果发生异常,消息框会出现“你想调试还是关闭...”,在我选择“调试”选项后,会出现新的奇怪消息框:
---------------------------
Warning
---------------------------
A debugger is attached to PresentationHost.exe but not configured to debug
this unhandled exception. To debug this exception, detach the current debugger.
An unhandled exception was raised from Microsoft .NET Framework v 1.0, 1.1, or 2.0,
but the current debugger is configured to debug Microsoft .NET Framework v4.0 code.
Examine the exception using the SOS tool.
---------------------------
OK
---------------------------
引以为傲的多目标在哪里?
有没有人遇到过同样的问题?
更新:
尝试使用“使用 URL 启动浏览器”选项进行调试。调试工作正常,但出现 SecurityException。所以这是可能的,只需要弄清楚如何让它与“启动外部程序”选项一起工作。
更新 2:
检查两种情况下实际加载的 PresentationHost:
“启动外部程序”- 来自 C:\Windows\System32\的最新版本 (4.0.31106.0)
“使用 URL 启动浏览器”- 来自 C:\Windows\winsxs\x86_wpf-presentationhostexe_31bf3856ad364e35_6.1.7600.16385_none_6fca8974817173aa 的旧版本 (3.0.6920.4902)
最佳答案
这是 Visual Studio 2010 RTM 中的错误:
https://connect.microsoft.com/VisualStudio/feedback/details/487949/debugging-external-application
解决方法:
- 分离并重新附加 - 确保正确指定“附加到”。
- 修改EXE的App.Config:
<configuration> <startup> <supportedRuntime version="v2.0.50727" /> </startup> </configuration>
关于c# - 无法使用 Visual Studio 2010 调试 XBAP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2630088/