question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default Blazor Client App fails throwing the build error[Blazor][Appbuilding]

See original GitHub issue

I am trying to create an ClientSide Blazor app but I am not even able to build the default blazor app present in the VS

C:\Users\anagniho\source\repos\BlazorApp8>dotnet build
Microsoft (R) Build Engine version 16.3.0-preview-19375-05+42c4c1370 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 30.65 ms for C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]

Build FAILED.

obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\_Imports.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\FetchData.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Index.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttributeAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
obj\Debug\netstandard2.0\RazorDeclaration\Pages\Counter.razor.g.cs(51,38): error CS0234: The type or namespace name 'LayoutAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?) [C:\Users\anagniho\source\repos\BlazorApp8\BlazorApp8.csproj]
    0 Warning(s)
    8 Error(s)

Time Elapsed 00:00:01.21

Selecting the server app question resolves the issue though. is there anything else that needs to be installed for making it work ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dazinatorcommented, Aug 15, 2019

I hit this issue when using the latest VS 2019 preview 2 to build my solution. My solution was pinned via a global.json file to use sdk preview 7, but I didn’t have sdk preview 7 installed, so the build rolled forward to use sdk preview 8. I have blazor preview 7 dependencies in my dependency graph, and it appears building under preview 8 with preview 7 dependencies, produced this error.

Rather than upgrade everything to preview 8 (some dependencies I use aren’t compiled and released for preview 8 yet and are still on preview 7) I did this to resolve:

  1. Install preview 7 sdk
  2. Ensure all dependencies in my application that target blazor are referencing preview 7 (not 6 or less)
  3. Add a global.json to my solution to pin to preview 7.
  4. run a dotnet build - success.
  5. I had VS open throughout this, a rebuild doesn’t seem to detect sdk 7 was installed and continues to use sdk 8 and fail - restarting VS, and reloading the solution, and then rebuilding - then correctly used sdk 7 and the build succeeded.

I assume this exact same thing can occur each time we go from preview x to preview y - lot of breaking changes at the moment - the build system seems to be very fragile - a bit like goldilocks porridge - everything has to be be “just right” 😃

1reaction
mkArtakMSFTcommented, Aug 14, 2019

@erikbra the package Microsoft.AspNetCore.Components.Browser was renamed to ``Microsoft.AspNetCore.Components.Web`.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build fail for Asp.Net Core 3 (Blazor client side)
Basically, as far as I understand it, somewhere in Mono the IL Linker fails and throws this cryptic error message.
Read more >
Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
Blazor Best Practices: Handling Errors
Errors are likely to occur, the question is how to handle them. Let's take a look at best practices in handling them in...
Read more >
Global HTTP Error Handling in Blazor WebAssembly
In this article, we are going to learn about handling HTTP errors in the Blazor WebAssembly application. We are going to start with...
Read more >
Blazor WASM: How to return 404 error?
I made a blazor wasm project (via template) in VS2022 and see that if I make a (client side) call to a missing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found