I've recently been converting a website project over to a web application project. The old website had a C# file in the App_Code folder which worked fine even though the rest of the project is in VB. Since I've converted the project to a web app, the .cs file will no longer compile, so I moved the .cs file to its own project to compile as a .dll and included it in the solution so it will compile seperately. The problem is that now when I run the site, I get a runtime error ref开发者_如何学编程ering to that dll:
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
I can't downgrade the .net framework of the .cs file because it uses System.Web.Linq, which only dates back to 3.5. When I try to change the framework of the web app it already shows up as 4.0 (which makes no sense to me). The version info for the server is:
Version Information: Microsoft .NET Framework Version:2.0.50727.3623; ASP.NET Version:2.0.50727.3618
Is there anyway to restore the old functionality without changing the .net framework on the server? Am I simply missing a configuration file or something?
Before upgrading the server, I would try upgrading the C# 3.5 project to 4.0. Could be that the error is occurring when the C# file tries to talk back to the web app.
EDIT: A better idea might be to downgrade your web app to 3.5. That way both parts of the app are on the same version and 3.5 should be able to run on a 2.0 server.
If you keep the framework at 2.0, try referencing "System.Core" and make sure "Copy Local"=true or you move that file manually to the server. You will need .NET 2.0 SP1 as well to make this work.
You probably need to change the version of the .NET framework that the application pool running the website is using. Make sure that the newer version of the framework is installed on the server, then follow the instructions at the bottom of this page, under "To associate an IIS application with the .NET Framework 4 in IIS 7.0": http://msdn.microsoft.com/en-us/library/dd483478.aspx
精彩评论