How to debug a .exe launched from Full​Trust​Process​Launcher

霸气de小男生 提交于 2021-02-08 05:27:14

问题


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.

I've tried the following:

  1. Set breakpoints within the WPF code.

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

  1. Attach to the running WPF process once the UWP launches it.

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

  1. I started investigating the new VS extension "Desktop Bridge Debugging Project" and followed along with samples and documentation.

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...

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}");
    }

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.

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

Thanks


回答1:


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.

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




回答2:


Advanced Installer (a MSFT partner) provides now an extension for Visual Studio 2015 and 2017 that can build an AppX (along with your MSI/EXE) package from a single project and also enables debugging for your application with a few clicks - much simpler than current solutions.

- watch video demo -



来源:https://stackoverflow.com/questions/44086262/how-to-debug-a-exe-launched-from-fulltrustprocesslauncher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!