1

Main Problem

The above is just one of over 1k+ errors in my C# project. I am using a 2017 MacBook Pro with Catalina 10.15.6. and VSCode. The dotnet-SDK I have is 3.1.401. I tried uninstalling and re-installing it but that didn't work. I had a project that was working perfectly then last night I did brew upgrade and today I have all of these errors. Of course I tried dotnet restore dotnet ef database update Those commands succeed in reinstalling the packages to the project directory and re-applying the database migrations (this project uses a postgres database in case that's important), but it still has all of those errors.

I was able to get the project working on Firefox after I re-created a new development SSL certificate.

When I tried to run the app and connect to `https://localhost:5001" like I always do I got this

"Secure Connection Failed An error occurred during a connection to localhost:5001. PR_END_OF_FILE_ERROR The page you are trying to view cannot be shown because the authenticity of the received data could not be verified. Please contact the website owners to inform them of this problem."

I fixed this with the following commands dotnet dev-certs https --clean and then dotnet dev-certs https And then it started to work fine on Firefox but I still got those 1k+ errors in VScode.

In Conclusion

The project works, I just have a ton of errors in VSCode and I'm not sure what's causing them.

Error Samples

  • The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
  • The type 'Task' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
  • The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)

4 Answers 4

4

I had the same issue and the way to solve it for me was:

  1. Install Nuget package Microsoft.AspNetCore.Mvc.RazorPages ( https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.RazorPages/ ) from .net CLI:

dotnet add package Microsoft.AspNetCore.Mvc.RazorPages --version 2.2.5

  1. Change your .csproj file, you have to add AddRazorSupportForMvc, so that it would look like this:
      <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
      </PropertyGroup>

The main issue is that Microsoft.AspNetCore.MVC namespace no longer exists.

Sign up to request clarification or add additional context in comments.

1 Comment

Worked for me. I had issue while updateing my blazor app .net5 to .net6
1

Please try

 dotnet dev-certs https --trust

https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx

5 Comments

This is a good command to know. Thank you! The problem though is that the C# linter seems to think that there is a bunch of code breaking errors even though I have the correct dotnet sdk installed. I am able to run the project, VSCode just thinks all of the dependencies are broken.
My pleasure :-) And maybe you can let us have a peek into some of the errors by adding them to your question?
I just updates the original post to include error samples.
Thanks Christian. This appears to me like .NET framework stuff, and your project is Core. Are you sure you are not including any old rubbish?
Yeah it worked 100% the day before the brew update and then all these errors showed up. I have isolated this to probably being an omnisharp issue (omnisharp is a program vscode uses for linting). Also, I commented on a newly made Github issue where someone else describes the same problem I have so I think this might be a bug in omnisharp. github.com/OmniSharp/omnisharp-vscode/issues/3990
1

The problem was fixed here: https://github.com/OmniSharp/omnisharp-vscode/issues/3990

When my dotnet core sdk updated to 3.1.401 it made it so that I had to change a setting in vscode involving mono.

I went to File > Preferences > Settings then searched "omnisharp use global mono" and changed the resulting value from "auto" to "never." This stopped the errors when linting.

Comments

1

I would like to add that while debugging this issue in your app, look for any occurrence of MVC. I ran into this issue in a Blazor WebAssembly app on .net 5, and discovered the problem was a seemingly innocuous SelectList property, which sits within the Mvc.Rendering namespace, in my shared class library assembly...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.