C# 无法加载文件或程序集 ':此程序集是由比当前加载的运行时更新的运行时构建的,无法加载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12131850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly ':This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded
提问by Susan
I Hvea 3 projects in my solution: BL, DL and the UI. All three projectshave a target framework of >NET 4; I have double-checked this by looking at the property page for each project. I am receiving the following error message when I try run the website at the hosting environment but not when I run it locally.
我的解决方案中有 3 个项目:BL、DL 和 UI。三个项目的目标框架都是>NET 4;我已经通过查看每个项目的属性页面仔细检查了这一点。当我尝试在托管环境中运行网站时收到以下错误消息,但在本地运行时却没有。
Could not load file or assembly 'BL' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Thanks in advance!
提前致谢!
采纳答案by Hassan Boutougha
You have to update your webservice extension to allow framework 4.0 in IIS. To enable the Web service extension for ASP.NET 4.0:
您必须更新您的 webservice 扩展以允许 IIS 中的框架 4.0。为 ASP.NET 4.0 启用 Web 服务扩展:
- Click Start, click Control Panel, click System Security, click Administrative Tools, and then click Internet Information Services (IIS) Manager.
- If you need to connect to a remote IIS Server, right click the Internet Information Services node and click the Connect... option.
- Type in the computer name for the remote IIS Server and credentials if necessary.
- Click the Web Service Extensions folder. The security lockdown console appears in the frame on the right.
- In the Web Service Extensions window, right-click the ASP.NET v4.X.XXXX, and then click Allow.
- 依次单击“开始”、“控制面板”、“系统安全”、“管理工具”,然后单击“Internet 信息服务 (IIS) 管理器”。
- 如果您需要连接到远程 IIS 服务器,请右键单击 Internet 信息服务节点并单击连接...选项。
- 如有必要,键入远程 IIS 服务器的计算机名称和凭据。
- 单击 Web 服务扩展文件夹。安全锁定控制台出现在右侧的框架中。
- 在 Web 服务扩展窗口中,右键单击 ASP.NET v4.X.XXXX,然后单击允许。
回答by user2721039
-Go to IIS. -Default WebSite-> Your application Directory->Advance Settings->Application Pool-> Set your Version (Ex. ASP.NET v4.0) -Refresh your Application Directory and Browse it. It's done.
- 转到 IIS。-默认网站->您的应用程序目录->高级设置->应用程序池->设置您的版本(例如ASP.NET v4.0)-刷新您的应用程序目录并浏览它。完成。
回答by Henrique Zacchi
You might also have to run ASP.NET IIS Registration tool (Aspnet_regiis.exe) - more details here
您可能还需要运行 ASP.NET IIS 注册工具 (Aspnet_regiis.exe) -此处有更多详细信息
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i
回答by jade290
I received the same error when I tried to upgrade my application from .NET 3.5 to .NET 4.5. When I reverted the changes (something when wrong, I'll figure it out later) I received the error:
当我尝试将我的应用程序从 .NET 3.5 升级到 .NET 4.5 时,我收到了同样的错误。当我恢复更改时(有些错误,我稍后会弄清楚)我收到了错误:
Could not load file or assembly 'XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
This dll was in my project's bin folder. When I deleted it the application ran as normal.
这个 dll 在我项目的 bin 文件夹中。当我删除它时,应用程序正常运行。

