如何调试从FullTrustProcessLauncher启动的.exe [英] How to debug a .exe launched from Full​Trust​Process​Launcher

查看:73
本文介绍了如何调试从FullTrustProcessLauncher启动的.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一解决方案中构建了一个UWP应用程序和一个WPF应用程序.我正在使用完全信任过程启动器类从UWP应用程序启动WPF应用程序.我也在使用App NESES才能允许两个App相互通讯.在基本情况下,所有这些都可以正常工作.但是一旦我真正开始开发超出示例的WPF应用程序,我就会发现我将需要在Visual Studio中开始调试.

I have built a UWP app, and a WPF app within the same solution. I am using the Full​Trust​Process​Launcher class to launch the WPF app from the UWP app. I am also using the App​Service​Connection class to allow the two apps to communicate with each other. This all works fine in a basic scenario. But once I start really developing my WPF app beyond the samples I can find I will need to start debugging in visual studio.

我尝试了以下操作:

  1. 在WPF代码中设置断点.

结果:我没想到它会起作用,而且没起作用.

Result: I did not expect this to work, and it did not.

  1. UWP启动后,附加到正在运行的WPF进程.

结果:选择正在运行的WPF进程时,附加"按钮显示为灰色.

Result: The "attach" button when the running WPF process is selected is grayed out.

  1. 我开始研究新的VS扩展"Desktop Bridge Debugging Project",然后是示例和文档.

结果:我能找到的所有示例似乎都围绕着将现有的WPF应用程序转换为UWP.因此,我认为这不是解决方案.我可能是错的...

Result: All of the samples I could find seemed to revolve around converting an existing WPF app to UWP. Because of this, I don't think this is a solution. I could be wrong...

以下是从UWP应用启动我的WPF应用的相关代码:

Below is the relevant code for launching my WPF app from the UWP app:

int messageNumber;
    private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    {
        if (this.messageNumber == 0)
        {
            await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
        }
        this.messageNumber++;

        await AppServiceManager.SendMessageAsync(
          $"Message number {this.messageNumber}");
    }

如上所述,目前我仅关注Microsoft的示例.我最终希望添加更复杂的代码并能够进行调试.

As I mentioned above, for now i'm just following the Microsoft examples. I would eventually like to add more complex code and be able to debug.

我还能从UWP应用启动的WPF应用获得调试功能吗?

How else can I get debugging features for the WPF app launched from a UWP app?

谢谢

推荐答案

为了调试UWP项目中的完全信任过程,您将必须在不调试的情况下启动UWP过程(或从中分离调试器).然后将调试器附加到完全信任过程,您的断点将被击中.

In order to debug the fulltrust process in your UWP project, you will have to start the UWP process without debugging (or detach the debugger from it). Then attach to the debugger to the fulltrust process and your breakpoints will be hit.

我意识到这不是理想的工作流程,我们正在努力在VS的未来更新中对此进行改进.

I realize this is not an ideal workflow, and we are working on improving this in a future update for VS.

这篇关于如何调试从FullTrustProcessLauncher启动的.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆