dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.05k stars 1.73k forks source link

Blazor Hybrid template doesn't work #23137

Closed arteeh closed 3 months ago

arteeh commented 3 months ago

Description

When I create a new Blazor Hybrid app with Visual Studio and launch it on Windows (unchanged), I get an exception on line 9 of MauiProgram.cs (var builder = MauiApp.CreateBuilder();):

System.InvalidProgramException: 'Common Language Runtime detected an invalid program.'

Exception source: Microsoft.Extensions.DependencyInjection.Abstractions

The program crashes after I continue.

Tried in Jetbrains Rider as well, got the same exception but in App.g.i on line 75 (if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();)

When I debug the template in Android 11 emulator, the app crashes on startup and my output says this:

[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Maui.Controls.Xaml.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Configuration.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Configuration.Abstractions.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.AspNetCore.Components.WebView.Maui.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Extensions.Logging.Debug.dll
...
[libc] Fatal signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0 in tid 18668 (name.hybridtest), pid 18668 (name.hybridtest)

Steps to Reproduce

  1. Install latest version of Visual Studio (Professional)
  2. Use the Visual Studio Installer to get MAUI
  3. Create .NET MAUI Blazor Hybrid App on .NET 8
  4. Set the launcher to windows instead of mac/android
  5. Debug
  6. Install whatever dotnet workloads you don't have when it tells you
  7. Debug again

Android:

  1. Install and launch an Android 11 emulator
  2. Set the launcher to android instead of windows/mac
  3. Debug

Jetbrains Rider:

  1. Create a new solution/project and select Other > MAUI > Target framework: .net8.0 and Type: Blazor Hybrid App
  2. Set the startup configuration to the windows one
  3. Debug

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

github-actions[bot] commented 3 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

arteeh commented 3 months ago

Already tried:

arteeh commented 3 months ago

I actually did experience this issue #19489 earlier, but now I can't reproduce it anymore. I saw it when I tried to run my old app which started this troubleshooting journey, and I think I saw it with a fresh template as well. Maybe it's gone because I ran dotnet new -i Microsoft.Maui.Templates?

But I just get crashes and InvalidProgramExceptions now.

arteeh commented 3 months ago

The problem was that I needed a certain Windows SDK. Probably Windows 10 10.0.19041.0, but I just installed all of them. You can find it under the 'Desktop development with C++' section (or Individual components) (makes sense for something maui clearly depends on).

Now both the templates and my old project run properly, including on my android emulator.