Search Unity

Question Can't connect Debugger to Hololens

Discussion in 'VR' started by Ozelotl, Aug 26, 2020.

  1. Ozelotl

    Ozelotl

    Joined:
    Sep 26, 2017
    Posts:
    11
    Hello,

    I'm unable to connect the Visual Studio Debugger to my application that is running on a Hololens 2.
    I've posted here before about a similar issue regarding connecting the Profiler which I got to work in the end.

    This also means that I triple checked the required Internet Capabilities (even in the manifest file) and they are enabled.
    I checked that multicast is supported on my network.
    I also added the code it said in here and tried manually inputting the IP address and port it gave me but when I click ok nothing happens (with no output or error).

    Thank you for any input!
     
  2. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    Hey,

    I'm following up on this and it doesn't appear there's been any response to your question on the Slack channel. I think the Device Portal and Script Debugging issues are related, and so I have some follow-up questions.

    Is the option to enable "Developer Mode" available? I'm assuming Developer Mode is available because your really can't do any dev work without it. Try turning it "Off", restart your HL2 device, and turn Developer Mode "On" again to see if that clears things up.

    Do you see some text at the top of the window (under "For Developer" settings) that says something like this:
    "*Some of these settings are hidden or managed by your organization." If this text is present, it means your HL2 is joined to a Domain in which Group Policy has disabled Developer features. I can't image this being the case, but it's one reason why the Device Portal setting is missing.

    Lastly, (sorry but gotta ask) have you updated your HL2 to the latest version?
     
  3. stenfeio

    stenfeio

    Joined:
    Jan 18, 2015
    Posts:
    22
    Had some issue mentioned above. Main change that got this to work for me is updating the Window's Firewall settings to allow Inbound communication with Visual Studio on my private network. Once I try attaching the debugger through Visual Studio it now works.
     
  4. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    Hey @stenfeio
    Thank you for providing information on this! Hopefully it'll help other people who hit this problem.

    I'm rather perplexed you had to manually configure the Windows firewall, because Visual Studio should add those rules during installation.
     
    stenfeio likes this.
  5. stenfeio

    stenfeio

    Joined:
    Jan 18, 2015
    Posts:
    22
    @timke Was assuming the same but unfortunately not the case:
    Exact instructions:

    You need to setup an Inbound Rule for Visual Studio to accept incoming multicasts coming from the HL2, setup only for private network:
      1. Open “Windows Defender and Firewall and Advanced Security” by searching in the start menu.

      2. Click “Inbound Rules” on the left explorer tab.

      3. Click “New Rule” in the right most tab.

      4. Choose “Program” for the type of rule then click “Next”.

      5. Choose “This Program Path” and navigate to your Visual Studio installation directory, typically “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE”. Choose “devenv.exe” as the program to choose. Click “Next”.

      6. Choose “Allow this Connection” then click “Next”.

      7. Choose only the “Private” checkbox and unlick “Domain” and “Public”. This should ensure you’re only allow inbound multicasts from your local network. Click “Next”.

      8. Give the rule a good name like “THIS RULE FINALLY FACILITATES GETTING A MANAGED DEBUGGER TO RUN ON HL2” and click “Finish”.

      9. Attempt the instructions to run a managed debugger in the microsoft documentation
     
    Last edited: Jan 19, 2022
  6. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    Hello,

    I have followed all the threads and tutorials I have found but I am still not able to connect VS to the hololens2 running applications.
    • I can connect to the Device portal ✔
    • I can connect the remote application the Unity Editor Profiler ✔
    • I can deploy to the remote device ✔
    • I cannot connect the debugger to the app, mainly because it does not appear in the Unity Instance ❌
    • I have added VS2022 inbound rule
    • I have added tried to manually inputting ip and port [https://forum.unity.com/threads/dep...iversal-windows-platform.539685/#post-3791227]
    Anyone needed to do something else to make this work?

    I still think that it's something about the firewall, because the device is available as remote device, but I don't know what else I can do.
    PS. It mentions something about authentication, but I don't think that's the issue

    Thank you

    Some Screenshots:

    upload_2022-7-19_16-15-33.png


    upload_2022-7-19_16-16-5.png

    upload_2022-7-19_16-17-31.png
     
  7. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    Hey @Maeslezo,

    I'm guessing you've already seen this SO post: https://stackoverflow.com/questions...c-sharp-project-on-hololens/59990792#59990792 and tried the suggestions included there.

    The big "gotchas": missing the Capabilities in your app Manifest and keeping HL plugged into USB when trying to attach the debugger. If you've already checked all of these things, I'm not sure what the problem is.

    I'm actually not working much on HoloLens anymore, but I'll ping the XR team to see if they have any other ideas/suggestions.
     
  8. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    Thank you @timke

    I finally managed to make it work, but I have tried so many things that I not sure which one was the key, but I think it's this one. I hope it helps:
    1. Create the generated vs solution: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/managed-debugging-with-unity-il2cpp
    2. Add these lines to the generated solution: https://forum.unity.com/threads/dep...iversal-windows-platform.539685/#post-3791227
    3. Set the remote machine: https://docs.microsoft.com/en-us/wi...sing-visual-studio?tabs=hl2#remote-connection upload_2022-7-20_11-41-54.png
    4. Debug->Start Debugging upload_2022-7-20_11-43-19.png
    5. In the output window, search for this line, which is the line that we added in step 2, and note the port upload_2022-7-20_11-47-43.png
    6. Now, keeping this vs solution attached (DO NOT STOP IT), go to the Unity Solution
    7. Debug->Attach Unity Debugger
    8. Input IP. And here, we are going to add, the ip of the Windows Device Portal and the port of step 5
    9. Now you get it, the Unity Solution should be attached to the hololens running app
     
    Last edited: Jul 20, 2022
  9. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    Well I'm glad you got it to work, but I definitely don't understand why you have to manually input the device's IP address into the Unity Debugger nor attach the VS native debugger.

    Since the Unity Debugger does actually attach if you give it the right address and port, my guess is this is the issue (from post #2):
    Although it could be a combination of factors as well...(UWP is such a pain)

    Unfortunately I don't think there's anything we (Unity) can do to improve this, and I suggest complaining on Microsoft's HoloDevelopers Slack channel, which you can join via this link: https://holodevelopersslack.azurewebsites.net/

    Hopefully you'll get better help from Microsoft devs :)
     
  10. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    I don´t understand either, but it is what it is .

    About connecting the VS native debugger, if I disconnect it, the Unity VS debugger gets also disconnected.
    Maybe the native debugger launches some kind of process that allows the debugger to be connected, I don´t know