aspnetcore: The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspnetCore' (are you missing an assembly reference?)
Describe the bug
in blazor project, When i update the .Net Core 3.0.0.Preview4 and then changes all the .cshtml in to .razor pages i have faced this issue “The type or namespace name ‘Mvc’ does not exist in the namespace ‘Microsoft.AspnetCore’ (are you missing an assembly reference?)”
Can one help me for how to resolve this?
Expected behavior
Need to be build succeed
Screenshots

Additional context
Add any other context about the problem here.
Include the output of dotnet --info

About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 54 (14 by maintainers)
Same situation here. 2 projects, 1 is building fine, another fails with this error. Both are client-side Blazor projects.
@Legends
Regarding VS Preview: note that you’re quoting a comment that refers to the then-new 16.1 Preview. Regardless, Blazor preview 7 and up does require VS 16.3 Preview to fully work, because it includes some Razor tooling changes:
The “Preview Features” SDK checkbox isn’t quite the same thing. What it does is allow you to use a .NET Core 3.0 preview from a non-preview VS at all. It does not, however, include the complete tooling for Blazor.
Note that VS previews will install side-by-side with the regular VS, so while it will take some time to install and take up a fair amount of disk space, it won’t really interfere with your production stuff.
I am facing the same problem for the last week!
Any solution yet?
@pranavkm:
More info: <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" /> <PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" /> </ItemGroup>
Annoying but not a killer: razor pages no longer accept single lines without {} eg. for(…) singleLine();
input & select onchange events no longer accept a method name. Throws this error: Error CS0029 Cannot implicitly convert type ‘void’ to ‘object’ Other errors I can’t fix: Error CS0103 The name ‘StateHasChanged’ does not exist in the current context Error CS0103 The name ‘PageContext’ does not exist in the current context Error CS0246 The type or namespace name ‘HttpClient’ could not be found (are you missing a using directive or an assembly reference?) Error CS0115 ‘_Pages_mypage_razor.OnInitAsync()’: no suitable method found to override
I am also having this issue. I have upgraded 2 solutions and one of them works fine and the other fails with this error. Candidate Release? I don’t think so.
Sorry I couldn’t help; just venting 😮{
@Legends That sounds pretty bad ☹️. To help diagnose your issue could you please report a Visual Studio Feedback ticket with the details on the problem you are seeing using the “Send Feedback” feature in VS? That will help us pin down what is happening for the specific VS version you are using.
@chucker Yes, that is exactly my experience. I’ve downloaded VS Preview yesterday running it side by side with the stable version. All Blazor app templates are available in VS Preview and everything is running fine.
Thanks for the info!
Google leads here for the error that comes from accidentally putting a semicolon in a cshtml file. e.g. I’d written
@Html.Partial("...");instead of@Html.Partial("...")I was facing this issue in VS 2019 preview5 and when I have changed some of the missing .cshtml files to .razor in the project, this issue get resolved.
@kmuthukumar23 Could you please share the project file for the project that fails to build with these errors?
Sorry @kmuthukumar23 if I hijacked your report