How to Debug Remote MAUI App Launch

Marc George 191 Reputation points
2025-07-01T10:53:00.0633333+00:00

I have a .NET 9 MAUI app being deployed to a remote Xcode iOS iPhone 16 Plus. All components have the latest release software. The deployment is successful, and the application is launched and the splash screen displayed on the phone. However, the first line of code, "InitializeComponent()" with a breakpoint applied is never reached. The app is terminated and the following debug output is generated.

INFO: Closing debug connection from device (USB) INFO: Disposing input and output streams... ERROR: An error occurred when writing to the output stream. Details: net_io_readfailure, Operation canceled INFO: Disposing input and output streams... INFO: Closing debug connection from remote debugger (TCP) ERROR: An error occurred while writing to the debug stream. Details: ObjectDisposed_Generic ObjectDisposed_ObjectName_Name, UsbStream INFO: Disposing console and debugger streams... INFO: An error occurred while forwarding HotReload local tunnel: System.IO.IOException: USB connect timeout (ENODATA), likely because the app failed to launch. Please review device logs and/or crash reports for more information. at Xamarin.MacDev.AggregateAsyncResult.CheckError(Boolean cancelled) at Xamarin.MacDev.IPhoneDevice.EndConnectStream(IAsyncResult result) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location --- at Xamarin.Messaging.IDB.IPhoneUsbLocalTunnelConnection.StartLocalTunnelAsync() at Xamarin.Messaging.IDB.LaunchAppMessageHandler.ForwardLocalTunnelsAsync(LaunchAppMessage, IPhoneDevice) ERROR: [iOS HotReload] Failed to connect to "iRogue" over USB on port 11000.

What is necessary to debug/fix the problem?

Developer technologies | Visual Studio | Debugging
0 comments No comments
{count} votes

10 answers

Sort by: Most helpful
  1. Gade Harika (INFOSYS LIMITED) 330 Reputation points Microsoft External Staff
    2025-07-08T15:07:44.08+00:00

    Thank you for sharing the details, Requirements After Port 11000 Is Open

    • App Must Stay Alive Long Enough   The app must not crash or terminate before the debugger attaches. You can delay execution slightly to give the debugger time:
    • Debug Symbols Must Be Present   Ensure the build includes symbols:
      • In Visual Studio:  Project > Properties > iOS Build > Enable Debug Symbols = true
    • Correct Entitlements and Provisioning   The app must be signed with a development provisioning profile that includes:
      • get-task-allow entitlement (allows debugger attachment)
      • Matching bundle ID and valid certificate
    • Tunnel Must Be Established   Visual Studio uses a USB or network tunnel to reach port 11000:
      • No firewall or antivirus should block it
      • usbmuxd or wireless pairing must be stable
      • The app must explicitly listen on 11000
    • Visual Studio Must Recognize the Device  The iPhone must appear in the Remote Targets list and be selected for deployment.
    • Debugger Must Attach Before App Terminates   If the app launches and exits too quickly, the debugger won’t hook in. A splash screen or artificial delay can help.

    Diagnostic Suggestions

    • Run netstat -an | grep 11000 on the Mac to confirm the port is listening
    • Check ~/Library/Logs/Xamarin/mtouch.log for tunnel or signing errors
    • Use Console.app or idevicecrashreport to inspect crash logs Requirements After Port 11000 Is Open
    • App Must Stay Alive Long Enough   The app must not crash or terminate before the debugger attaches. You can delay execution slightly to give the debugger time:
      • Debug Symbols Must Be Present   Ensure the build includes symbols:
      • In Visual Studio:  Project > Properties > iOS Build > Enable Debug Symbols = true
      • Correct Entitlements and Provisioning   The app must be signed with a development provisioning profile that includes:
      • get-task-allow entitlement (allows debugger attachment)
      • Matching bundle ID and valid certificate
      • Tunnel Must Be Established   Visual Studio uses a USB or network tunnel to reach port 11000:
      • No firewall or antivirus should block it
      • usbmuxd or wireless pairing must be stable
      • The app must explicitly listen on 11000
      • Visual Studio Must Recognize the Device  The iPhone must appear in the Remote Targets list and be selected for deployment.
      • Debugger Must Attach Before App Terminates   If the app launches and exits too quickly, the debugger won’t hook in. A splash screen or artificial delay can help. Diagnostic Suggestions
      • Run netstat -an | grep 11000 on the Mac to confirm the port is listening
      • Check ~/Library/Logs/Xamarin/mtouch.log for tunnel or signing errors
      • Use Console.app or idevicecrashreport to inspect crash logs await Task.Delay(3000); // Optional delay before InitializeComponent. Let us know if the issue persists after following these steps. We’ll be happy to assist further if needed.

  2. Gade Harika (INFOSYS LIMITED) 330 Reputation points Microsoft External Staff
    2025-07-09T10:45:22.9033333+00:00

    Thank you for sharing the details.

    Visual Studio 2022 introduced a new debugging architecture for .NET MAUI and Xamarin apps that relies on WebSocket-based tunnels over USB. Port 11000 is now the default for this tunnel, replacing older mechanisms like port 62078, which was previously used by Apple’s lockdownd service for device communication.

    This change was made to support Hot Reload, Live Visual Tree, and Live Property Explorer features—but it’s also more sensitive to USB stability and firewall interference.

    The Last Version Using Port 62078?

    Port 62078 was used implicitly by older Xamarin tooling and Visual Studio versions prior to the MAUI transition. Specifically:

    Visual Studio 2019 and early Visual Studio 2022 (pre-17.2) versions still relied on the legacy Xamarin debugger stack, which piggybacked on Apple’s port 62078 for device communication.

    After VS 2022 17.2, the debugger tunnel was reworked to use port 11000 explicitly.

    So if you want to test with the older port behavior, Visual Studio 2022 version 17.1 or earlier is your best bet.

    to Debug Remote MAUI App Launch

    Since the debugger fails to attach and the app exits before hitting InitializeComponent(), here’s how to proceed:

    1. Enable Verbose Logging

    Add this to your .csproj:

    xml

    <MtouchExtraArgs>--verbose</MtouchExtraArgs>
    

    This will give you detailed build and launch logs.

    1. Inspect Device Logs

    Use Xcode > Devices and Simulators or Console.app to check crash logs. Look for exceptions in AppDelegate, SceneDelegate, or MainPage.xaml.cs.

    1. Wrap Startup in Try-Catch

    Add logging around InitializeComponent():

    csharp

    try
    {
        Console.WriteLine("App starting...");
        InitializeComponent();
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Startup error: {ex}");
    }
    
    1. Test with a Minimal MAUI App

    Deploy a blank MAUI app to the same device. If it works, the issue is likely in your app’s startup logic or native bindings.

    1. Try Android Deployment

    Android debugging is more forgiving and doesn’t rely on the same USB tunnel. If port 11000 is open, it should work fine—though you may need to configure firewall rules.

    Let me know if the issue persists after following these steps. I’ll be happy to assist further if needed.


  3. Gade Harika (INFOSYS LIMITED) 330 Reputation points Microsoft External Staff
    2025-07-10T04:32:10.3233333+00:00

    Thank you for sharing the details.

    Visual Studio doesn’t require port 11000 to be open in the traditional firewall or network sense. Instead, it uses port 11000 as a local endpoint for a USB-based WebSocket tunnel between your development machine and the iOS device (via the Mac build host). This tunnel is internal—it doesn’t go through your router or public network—so the port just needs to be available locally, not externally open.

    However, if something blocks or interferes with that port—like:

    A firewall or antivirus tool restricting local traffic

    Another process already using port 11000

    USB instability or driver issues

    A misconfigured proxy or VPN

    …then the tunnel fails, and the debugger can’t attach.

    How to Resolve It

    Check for port conflicts: Run netstat -ano | find "11000" to see if another process is using it.

    Temporarily disable firewall/antivirus: Just to test if they’re interfering with local port access.

    Restart USB services: On your Mac build host, run:

    bash

    sudo killall -9 usbmuxd

    sudo killall -9 mtouch

    Then reconnect your iPhone.

    Try Wi-Fi debugging: Enable wireless debugging in Xcode and Visual Studio to bypass USB entirely.

    Disable Hot Reload: It often destabilizes the tunnel. Go to Tools > Options > Debugging > .NET MAUI Hot Reload and turn it off.

    Let me know if the issue persists after following these steps. I’ll be happy to assist further if needed.


  4. Gade Harika (INFOSYS LIMITED) 330 Reputation points Microsoft External Staff
    2025-07-21T06:36:15.59+00:00

    Thank you for sharing the details.

    Since you've confirmed that port 11000 is closed and debugging works on Android but not iOS, this appears to be a transport-layer issue specific to iOS tooling in the latest MAUI template.

    Recommended Next Steps

    1. Switch to Wi-Fi Debugging
      • USB debugging relies on port 11000, which is blocked in your setup.
      • Try pairing your iPhone wirelessly with Xcode and enable Wi-Fi debugging in Visual Studio.
      • Ensure both devices are on the same network and not using Personal Hotspot mode.
    2. Update .lldbinit Timeout
      • If the app is large or has many dependencies, it may be timing out before the debugger attaches.
      • On your Mac, create or edit ~/.lldbinit and add: settings set plugin.process.gdb-remote.packet-timeout 300
      • Restart Xcode and Visual Studio, then try debugging again.
    3. Use iOS Simulator Temporarily
      • If the physical device fails to launch, test on the simulator to confirm app behavior.
      • This can help isolate whether the issue is device-specific or tooling-related.
    4. Submit Additional Logs If possible, attach device logs from Xcode’s Devices window and mtouch logs from the Mac.
      • These can help us pinpoint where the launch or tunnel is failing.
      Let me know if the issue persists after following these steps. I’ll be happy to assist further if needed.

  5. Marc George 191 Reputation points
    2025-07-29T01:25:42.6733333+00:00

    Still at it. Been trying to finalize the app's migration on an Android phone for the past two day because I can debug on it. I did build a release version and was able to deploy it and see it start up. I plan on doing it again once it runs properly on the droid.

    I did do some testing which Apple suggested on Friday. It appears that port issue is not necessarily associated with the iPhone, but I am waiting for a deeper analysis from them of the results. Those results are posted on the VS teams' issue chain.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.