I have an IL2CPP Unity App which uses custom-made native DLLs built for HoloLens 2.
Debugging the managed C# code of the running App works just fine using Visual Studio 2019 with Tools for Unity Plug-In via Debug->Attach Unity Debugger. It automatically detects the App running on HL2 and I can connect to it.
I am also able to debug my native library C++ code by adding its source project to the generated IL2CPP solution. When I press the "Play"-Button, VS builds and deploys the UWP app to the HL2 and automatically attachs the Debugger, which allows me to debug my custom native code running on the device as well, which is great so far.
BUT how can I attach the VS native debugger to the App, when it was started manually on HL2? The problem is, that using the "Play"-Button, it always re-deploys the whole app to HL2, even if no code changes were made - and this process always takes very long time, which is really annoying.
I thought, it would work via Debug->Attach to Process, but I can not get a connection to the HL2, neither using its net name nor the IP address of the HL2 as Connection Target. The USB cable is also connected. Every attempt fails with the following error message:
"Unable to connect to the Microsoft Visual Studio Remote Debugger named '192.168.1.21'. The Visual Studio 2019 Remote Debugger (MSVSMON.EXE) does not appear to be running on the remote computer. This may be because a firewall is preventing communication to the remote computer. Please see Help for assistance on configuring remote debugging."
Error message on trying to attach native debugger to IP
When deploying the App to HL2 via "Play"-Button, I recognized the port number 55142 mentioned in the debug output:
Debugger listening port shown in the Debug Output
So I tried to attach the Debugger directly to this port, but doing so leads to a different error message:
"Unable to connect to the Microsoft Visual Studio Remote Debugger named '192.168.1.21:55142'. Connection request was rejected by the remote debugger. Ensure that the remote debugger is running in 'Windows Authentication' mode."
Error message on trying to attach native debugger to IP:Port
Any ideas?
If you want to debug an installed app on HoloLens, this doc is worth reading through: Debugging an installed or running app.
The following are the specific steps shown in the documentation for debugging a Universal Windows app that's installed without deploying from a Visual Studio project:
- Go to Debug -> Other Debug Targets -> Debug Installed App Package
- Select the Remote Machine target for HoloLens or Local Machine for immersive headsets.
- Enter your device’s IP address
- Choose the Universal Authentication Mode
- The window shows both running and inactive apps. Pick the one what you’d like to debug.
- Choose the type of code to debug (Managed, Native, Mixed) Click Attach or Start