Skip to content

.NET 6 app crashes on start in Debug mode #6961

@jonathanpeppers

Description

@jonathanpeppers

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 6 / MAUI RC 1

Description

From @RedChops here: dotnet/maui#6460 (comment)

I can't get any iteration of HttpClient working (managed or native). Native crashes the app immediately on launch, Managed acts incredibly strangely. It appears to crash from a NullReferenceException, but sometimes it crashes silently, causing all code that would otherwise use the result of SendAsync to be skipped.

For example:

  1. var result = await client.SendAsync(...);
  2. var content = await result.Content.ReadAsStringAsync()
  3. [something else]

If I set a breakpoint on line 2, that breakpoint will get skipped and code will continue to execute on line 3, causing both result and content to be null.

I spent a large part of the day uninstalling all VS versions, clearing out the dotnet folder of all SDKs, reinstalling everything, etc, so everything should be clean and at the latest version.

Steps to Reproduce

I've attached here a small reproduction project.

NetworkTest.zip

Did you find any workaround?

No

Relevant log output

The first is AndroidClientHandler.adb.txt which is the output from using the Android HttpClient.

The second is HttpClientHandler.adb.txt. This of course includes the output from the AndroidClientHandler log since it's the same emulator boot.

Both of these logs were generated off that sample project which I created fresh specifically for this bug, so there shouldn't be anything else weird going on there. They also both were run in Debug mode with <RunAOTCompilation>False</RunAOTCompilation> set in the csproj.

Metadata

Metadata

Labels

Area: Mono RuntimeMono-related issues: BCL bugs, AOT issues, etc.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions