如何在VS2010中调试已发布的XBAP文件?

我需要通过指定URL来调试完全信任的应用程序,或者理想情况下,从我打算将其部署到的Web应用程序中调试。 我尝试过以下方法:

  • 从命令行运行“PresentationHost.exe -embedding”,通过Visual Studio附加。 IDE显示我的断点有效,直到我实际尝试加载.xbap文件,此时它显示没有加载符号。 没有一个断点被击中。 在其他地方提出几项建议之前,我已尝试过“mage -cc”。

  • 项目的Debug面板中的硬编码URL,然后是F5。 或者,“PresentationHost.exe -embedding -debug”并附加到进程然后在IE中加载.xbap。 当页面出现时,两者都会导致以下错误:

System.ArgumentException:不支持URI格式。

at System.IO.Path.NormalizePath(...) at System.IO.FileStream.Init(...) at System.IO.FileStream..ctor(...) at System.Windows.Interop.ApplicationLauncherXappDebug.GetIdFromManifest(...) at System.Windows.Interop.ApplicationLauncherXappDebug.GetApplicationIdentity() at System.Windows.Interop.ApplicationLauncherXappDebug.Initialize() at System.Windows.Interop.DocObjHost.MS.Internal.AppModel.IBrowserHostServices.Run(...) 

找到了。 如果您选择要发布的.pdb文件,则“PresentationHost.exe -embedding”将起作用,默认情况下不是这样。 这是从我之前看到的,一旦应用程序实际加载,调试器似乎有符号然后没有。 澄清:

  • 进入项目属性的“发布”选项卡
  • 单击“应用程序文件…”
  • 选中“显示所有文件”
  • 选择要包含的可执行文件的.pdb文件。
  • 重新发布
  • PresentationHost.exe -embedding
  • 附加到进程或设置项目以从调试选项卡中运行它
  • 在浏览器中启动网页并导航到xbap文件,现在应该点击断点。

如果您有权访问源代码并在localhost上部署,则只需添加System.Diagnostics.Debugger.Launch(); 在你的代码中。 这将允许您将VS附加到XBAP正在使用的任何进程。