visual studio Maui Bluetooth error

Eduardo Gomez 4,056 Reputation points
2025-10-22T09:32:06.7733333+00:00

This is a very weird error, and is bugging me a lot

I am using Bluetooth

The problem

When I am debugging in visual studio, the app start and crashes after 6 seconds, however when you run the app directly, it will not crash

the app running within visual studio

Crash

Untitled video - Made with Clipchamp

the app running form my phone

Runs normally

Untitled video - Made with Clipchamp (1)

I don't know if a visual studio error is

Developer technologies | .NET | .NET MAUI
{count} votes

Answer accepted by question author
  1. Tony Dinh (WICLOUD CORPORATION) 3,585 Reputation points Microsoft External Staff
    2025-10-23T03:55:14.28+00:00

    Hello @Eduardo Gomez !

    Based on the information you've provided, the problem seems to be related to the debugging process itself rather than your application logic, especially since it works fine in Release mode.

    A common cause for this kind of behavior is "Application Not Responding" (ANR) error, a timeout in the Android operating system, which can be triggered when the debugger is attached. The debugger can sometimes pause threads for inspection, and if a critical thread like the main UI thread is paused for too long (even for a few seconds), Android may terminate the application, assuming it has become unresponsive.


    To prevent the debugger from breaking on these specific exceptions and allow your application to handle them gracefully, you can configure the debugger settings in Visual Studio:

    • In Visual Studio, go to the Debug > Windows > Exception Settings menu.
    • In the Exception Settings window, use the search box to find the following exceptions and uncheck them:
      • Java.Lang.Error
      • Java.Lang.Throwable

    This means that you are telling the debugger not to break when these exceptions are thrown, which can prevent the debugger-induced ANR and allow your app to continue running.


    If the issue persists after changing these settings, it would be helpful to get more information from the device logs. You can view these logs using the Device Log tool in Visual Studio while your application is running.

    • Connect your physical device.
    • Go to Tools > Android > Device Log to open the logcat viewer.
    • Start debugging your application (F5).
    • When the application crashes, stop debugging and examine the logs in the Device Log window for any errors or warnings that occurred around the time of the crash. Look for messages related to your application's package name.

    I hope this helps!

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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