问题
I have built a UWP app, and a WPF app within the same solution. I am using the FullTrustProcessLauncher class to launch the WPF app from the UWP app. I am also using the AppServiceConnection 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:
- Set breakpoints within the WPF code.
Result: I did not expect this to work, and it did not.
- 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.
- 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