question

RodAtWork avatar image
0 Votes"
RodAtWork asked YijingSun-MSFT commented

Getting several errors in the _Layout page, could they be caused by downgrading the .NET Framework?

I'm working on a simple ASP.NET MVC app. Originally, I started using .NET Framework 4.7.2, but then I discovered that the web server this app will eventually use doesn't support .NET Framework 4.7.2. (It was an irritating discovery as most of our web servers do support .NET Framework 4.7.2.) That server does support .NET Framework 4.6.2, so I downgraded the project to .NET Framework 4.6.2.

However, when looking at the _Layout.cshtml page in VS 2019, there's 56 errors such as CS0234 ('Net' does not exist in the namespace 'System'), CS0518 ('System.Void' is not defined), CS0012 (type 'Object' is defined in an assembly that is not referenced), etc. All of these are coming from a project named 2_Views_Shared_Layout.csthml, which I presume is an intermediate file created by VS 2019 when building the app.

I've created cleaning the solution, then performing a rebuild of the solution. That didn't help, the errors all returned.

The app does run, as far as I can tell, fine. At least it runs fine when I debug it using VS 2019.

But I'd like to remove those errors. I'm guessing that they're caused because I originally started the project as a .NET Framework 4.7.2, then had to downgrade it to .NET Framework 4.6.2. Am I correct about that?

In any case how do I get rid of those errors?

dotnet-aspnet-mvc
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered YijingSun-MSFT commented

Hi @RodAtWork ,
Maybe your problem is that you downgrade the framwork. You could try to create a new .net 4.6.2 project and migrate your old project.
Best regards,
Yijing Sun


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @YijingSun-MSFT ,

So, I should just create a new .NET Framework 4.6.2 project, then just copy all the files from the older project into it, correct?

0 Votes 0 ·

So, I should just create a new .NET Framework 4.6.2 project, then just copy all the files from the older project into it, correct?

The alternative is to share the entire project with the community so the community can see what you're doing. It sounds like messed up references but we cannot see the code. You could also hire an expert to help.

Honestly, if 4.6.2 is running on the server then installing 4.7.2 is not a big leap forward. Usually you want the latest .NET version on the server which is now 4.8; the latest and last version. Also, .NET 4.7+ is TLS 1.2 compliant if you need an argument to install the latest version.


0 Votes 0 ·

Hi @RodAtWork ,
I think,you could copy some codes you write and other you could add if the system need. Because I think,maybe you lose something in the old project.So,I don't recommend copy the old project completely.
Best regards,
Yijing Sun

0 Votes 0 ·