How to Debug Remote MAUI App Launch

Marc George 211 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

13 answers

Sort by: Most helpful
  1. Gade Harika (INFOSYS LIMITED) 490 Reputation points Microsoft External Staff
    2025-08-18T11:51:04.4066667+00:00

    Thanks for the update

    Step-by-Step MAUI Debugging Fix

    1. Configure launchSettings.json

    • Open launchSettings.json
    • Add the following:
    {
      "profiles": {
        "MyApp": {
          "commandName": "Project",
          "remoteDebugEnabled": true,
          "remoteDebugMachine": "DEVICE_IP"
        }
      }
    }
    
    • Replace DEVICE_IP with the actual IPv4 address of the target device (use ipconfig to find it)

    2. Set up the remote debugger

    • On the target device:
      • Install the exact matching version of Visual Studio Remote Tools
        • Run msvsmon.exe as Administrator
          • Use this command: msvsmon /noauth /anyuser /timeout:30000
          • On your development machine:
            • Disable Hot Reload in Visual Studio: Tools > Options > Debugging > .NET MAUI
              • Delete bin, obj, and .vs folders to clean the project

    3. Configure firewall and network

    • Temporarily disable firewalls and antivirus on both machines
    • Open UDP port 11000 and TCP port 4024
    • Make sure both devices are on the same subnet (e.g., 192.168.1.x)
    • Test connection using PowerShell:
    Test-NetConnection DEVICE_IP -Port 4024
    

    4. Adjust project settings

    • Open your .csproj file and ensure:
    <PropertyGroup>
      <ApplicationId>com.company.myapp</ApplicationId>
      <WindowsPackageType>MSIX</WindowsPackageType>
    </PropertyGroup>
    
    • Make sure ApplicationId is under 50 characters and has no underscores
    • Uninstall the app from the target device
    • Run dotnet clean
    • Build with dotnet build -c Debug
    • Deploy using Visual Studio with x64 platform selected

    5. Validate environment

    • Check remote debugger logs at: C:\Users\[user]\AppData\Local\Temp\RemoteDebugger
    • Enable detailed Visual Studio logging:
    devenv.exe /log output.log
    
    • Try deploying a blank MAUI app to isolate the issue

    6. Troubleshoot specific errors

    • For error 0x80131c08:
      • Delete Properties/launchSettings.json
        • Recreate the debug profile via project properties
        • If the app crashes before InitializeComponent():
          • Check logs:
            - Windows: Event Viewer > Windows Logs > Application
            
                  - Android: `adb logcat`
            
                        - iOS: Xcode Devices window console
            
                        - For connection timeouts:
            
                           - Use a wired connection instead of Wi-Fi
            
                              - On iOS, disable Wireless Debugging in bundle signing options
            

    7. Final checklist

    • Remote Tools version matches Visual Studio
    • msvsmon is running with no authentication
    • Firewalls are disabled during testing
    • Correct IP is set in remoteDebugMachine
    • App is uninstalled from the target device
    • ApplicationId is valid (no underscores)
    • bin and obj folders are deleted before rebuild

    8. If issues persist

    • Share the full error message from Visual Studio’s Output window
    • Include logs from the Remote Debugger folder.

    If stuck, run the Remote Debugging Troubleshooter:  

    ' msvsmon /prepcomputer` on target device (requires admin)

    Let me know if the issue persists after following these steps. I’ll be happy to assist further if needed. If the issue has been resolved, kindly mark the response as answered

    0 comments No comments

  2. Ben Caldwell 0 Reputation points
    2025-08-19T10:16:46.7166667+00:00

    This kind of crash (app terminating before hitting InitializeComponent()) when deploying a .NET MAUI iOS app remotely usually indicates that the app is failing during initialization before managed code is reached. Here are a few things you can try to debug:

    Check device logs

    Use Xcode → Devices and Simulators → View Device Logs to see the actual crash reason.

      Often it will be something like a missing permission, corrupted provisioning profile, or a linker issue.
      
      **Provisioning profiles & certificates**
      
         Make sure your developer provisioning profile matches the app bundle ID.
         
            If you recently updated to .NET 9 / Xcode 16, try regenerating the provisioning profile from Apple Developer Center.
            
            **App startup issues**
            
               If you’re doing any heavy work in `App.xaml.cs` or `MauiProgram.cs`, move it to a later lifecycle event.
               
                  Sometimes the linker trims required assemblies — test with `LinkMode=None` in your iOS project.
                  
                  **Hot Reload conflicts**
                  
                     The error `Failed to connect … over USB on port 11000` points to Hot Reload failing.
                     
                        Try disabling Hot Reload (`Tools → Options → MAUI → Hot Reload`) and redeploy. If the app runs, then re-enable step by step.
                        
                        **Clean + Rebuild**
                        
                           Delete `bin` and `obj` folders manually, then clean and rebuild.
                           
                              Also, remove the app from the device before redeploying.
                              
    

    If the device logs confirm that the crash happens before InitializeComponent(), the root cause is usually provisioning or startup configuration rather than your XAML code.

    We recently wrote about handling complex builds and visual layers for mobile apps & wraps on our site, since reliability is key whether you’re shipping software or physical designs. You can check it out here: TeckWrap UK.

    0 comments No comments

  3. Marc George 211 Reputation points
    2025-08-22T07:02:12.12+00:00

    Since it has been two months since the original issue filing, I have decided to replace the base code from the Maui App template. As a result, I have been able to build, deploy, execute and debug. I will begin migration of the remainder of the app code.

    Thanks for your efforts on my behalf. This issue can be closed.


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.