Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Web App template fails to compile when selecting Auto, Global #50980

Closed
danroth27 opened this issue Sep 28, 2023 · 10 comments
Closed

Blazor Web App template fails to compile when selecting Auto, Global #50980

danroth27 opened this issue Sep 28, 2023 · 10 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@danroth27
Copy link
Member

danroth27 commented Sep 28, 2023

Repro steps:

  • Install .NET 8 RC2 (8.0.100-rc.2.23477.19)
  • Create a Blazor Web App template with Auto selected for the interactivity type and Global for the interactivity location
  • Build and run

Expected result: App builds
Actual result:

C:\Users\user\source\repos\BlazorApp1Test\BlazorApp1Test.Client\Pages\Error.razor(28,33,28,44): error CS0246: The type or namespace name 'HttpContext' could not be found (are you missing a using directive or an assembly reference?)

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Sep 28, 2023
@jinzhao1127
Copy link

This issue also repro when selecting WebAssembly, Global

@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Sep 28, 2023
@mkArtakMSFT mkArtakMSFT added this to the 8.0 milestone Sep 28, 2023
@wtgodbe wtgodbe modified the milestones: 8.0, 8.0.0 Oct 3, 2023
@jinzhao1127
Copy link

Verify this bug was fixed on the latest .NET 8.0-rtm build.

@Alan-Steadman
Copy link

So cannot use 8 RC2? to trial blazor??? Have to wait for RTM version??

@danroth27
Copy link
Member Author

So cannot use 8 RC2? to trial blazor??? Have to wait for RTM version??

Hi @Alan-Steadman. This compilation error has an easy workaround: just copy the Error.razor file from the client project to the server project.

@Alan-Steadman
Copy link

Thanks - looks like I've got a similar-looking but different issue then:

Create new "Blazor Web App" (called "ffs", Auth Type = none, Interactivity Type = Auto, Per Page/Component)

Try to build... build fails saying (twice) "error CS0246: The type or namespace name 'ffs' could not be found (are you missing a using directive or an assembly reference?)". The two errors appear in the error list (program.cs, line 1, "using ffs.Client.Pages" and line 2 "using ffs.Components". When double clicking the errors, the program.cs file opens with red squiggles on those two lines, which promptly disappear after a few seconds, and disappear from the error list, but any attempt to build or run result in the same build error, but the errors don't then appear in the error list.

I'm using VS 2022 17.7 with the option enabled to use previews of the .Net SDK, I've got .Net SDK 8 RC2 installed and I've restarted, and created three projects and all have the same issue.

Should I log this as a new issue?

@danroth27
Copy link
Member Author

danroth27 commented Oct 19, 2023

I'm using VS 2022 17.7 with the option enabled to use previews of the .Net SDK

@Alan-Steadman You need to use VS 2022 17.8 with .NET 8. While in some cases using 17.7 may work with .NET 8 projects, there are known incompatibilities. Please try the latest 17.8 preview and verify whether it resolves your issue.

@Alan-Steadman
Copy link

Thanks @danroth27, much appreciated. Yes, I've installed VS2022 17.8 Preview following these steps and it works. Many thanks for your help!

@peterhvogel
Copy link

Just used the Blazor Web App template with Visual Studio 17.8.0 Preview 7.0 and ASP.NET and Web Tools 17.8.350.26616 and had this problem.

@danroth27
Copy link
Member Author

HI @peterhvogel. This issue is fixed for the upcoming .NET 8 release, but you can work around it with .NET 8 RC2 by moving Pages/Error.razor from the client project to the server project. See https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-rc-2#known-issues for details.

@peterhvogel
Copy link

peterhvogel commented Nov 10, 2023 via email

@dotnet dotnet locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

7 participants