2

When first time to create new project of type MudBlazor it return this error message : Found markup element with unexpected name 'MudNavMenu'

I create the project through CLI:

dotnet new mudblazor --host wasm --name MyApplicationName

And error never gone after updating or restoring packages or restarting visual studio 2019

Any Ideas?

enter image description here

Update:

I got this error after while :

Severity    Code    Description Project File    Line    Suppression State

Error   NETSDK1045  The current .NET SDK does not support targeting .NET 6.0.  Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.    MudBlazorApplication    C:\Program Files\dotnet\sdk\5.0.410\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets   141

I have SDK 6 and runtime installed already

enter image description here

  • 1
    Try adding an @using directive on the component for the correct assembly to see if that cures the problem? Why VS 2019 rather than 2022? – MrC aka Shaun Curtis Jul 20 '22 at 21:12
  • tried before, nothing happened – Waleed Aladin Jul 20 '22 at 22:14
  • I cannot reproduce that. After `dotnet new mudblazor --host wasm --name MyApplicationName` it works just fine. Forget about the IDE for the time being. What happens when you do `dotnet restore` and then a `dotnet run` from the root of the solution? – Bart Kiers Jul 21 '22 at 06:13
  • Oh, I just saw the error: the template creates a dotnet 6 project, while you have dotnet 5 installed. Either update your dotnet SDK to 6, or downgrade all packages to work with dotnet 5 in your csproj file. – Bart Kiers Jul 21 '22 at 08:48
  • @Bart Kiers I'm using visual studio 2019 , and I have SDK 6 installed – Waleed Aladin Jul 22 '22 at 14:56
  • I believe Visual Studio 2019 does not support .NET6: https://stackoverflow.com/questions/69773547/visual-studio-2019-not-showing-net-6-framework – T.Trassoudaine Jul 22 '22 at 15:13
  • @WaleedAladin like I said: forget about the IDE (which seem to not support dotnet 6 anyway), what happens when you run the project from your console? – Bart Kiers Jul 22 '22 at 18:16

2 Answers2

0

I just encountered this problem with several of my components. They had been working fine for a long time then suddenly I received this error and the component would not render. This is even though in the editor the component validated.

The cause of the problem is that when updating VS it also upgraded my machine to .net SDK 7.0.302. There is a bug in that version which will cause this problem when a blazor component is inherited.

To resolve the problem, downgrade to SDK 7.0.203.

You do this by creating a global.json file.

If, like me, you do not know how to do this, it is easy:

  1. From the root folder of your solution, enter the following command:
  2. dotnet new globaljson --sdk-version 7.0.203

That's it. That is all you have to do.

Skattch
  • 11
  • 1
-1

I had to recreate the project through Visual studio 2022 and changed the MudBlazor project type to server instead of host wasm and It works now I don't know if WebAssemblyHostBuilder is not compatible with SDK 6.0 or what