Missing namespaces when downgrading to asp.net 4.0

2019-07-30 12:32发布

问题:

I just had to downgrade my ASP.Net 4.5 application to an ASP.Net 4.0 application, because our servers don't support 4.5. The way I downgraded it was pretty simple:

Project -> Properties -> Application -> Target Framework

When it finished doing stuff, I restarted the solution, tried to start debugging, but it stopped right after I started debugging, giving me first some errors (which say they can't find some namespaces) for a fraction of a second and after the errors disappeared it gives me 127 warnings that all look like this:

Now I know what the problem is here, but I don't know how to solve this issue.. Does anyone know how to fix these warnings?

Thanks in advance

INFO

I'm using Visual Studio 2015 Community

回答1:

Remove your current references to the Dlls in question and them add them again, it should load the correct versions of the Dlls. Because you had references to the 4.5 versions and then changed the project target the references are invalid now because they are build against a higher version framework. Changing the projects framework version target does NOT update the references in most cases



回答2:

It is actually not that easy when it comes with ASP.NET. You have to go through all web.config(s) and downgrade referenced libraries. If its new project, just create new ASP.NET on .NET 4 and compare its web.config(s) with yours.