【问题标题】:Could not load file or assembly ':This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded无法加载文件或程序集':此程序集由比当前加载的运行时更新的运行时构建,无法加载
【发布时间】:2012-08-21 08:14:03
【问题描述】:

我的解决方案中有 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.

提前致谢!

【问题讨论】:

  • 您是否检查了生产服务器上网站的 iis 设置、已用应用程序池的目标框架?

标签: c# linq-to-entities asp.net-4.0


【解决方案1】:

检查 app.config 文件中的这一行,查看 .NET Framework 版本是否正确,如果不正确,请将其更改为应用程序属性中设置的版本。

【讨论】:

    【解决方案2】:

    当我尝试将我的应用程序从 .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.
    

    这个 dll 在我项目的 bin 文件夹中。当我删除它时,应用程序正常运行。

    【讨论】:

      【解决方案3】:

      您可能还需要运行 ASP.NET IIS 注册工具 (Aspnet_regiis.exe) - more details here

      C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i
      

      【讨论】:

        【解决方案4】:

        您必须更新您的 web 服务扩展以允许 IIS 中的框架 4.0。为 ASP.NET 4.0 启用 Web 服务扩展:

        1. 依次单击“开始”、“控制面板”、“系统安全”、“管理工具”和“Internet 信息服务 (IIS) 管理器”。
        2. 如果您需要连接到远程 IIS 服务器,请右键单击 Internet 信息服务节点并单击连接...选项。
        3. 如有必要,键入远程 IIS 服务器的计算机名称和凭据。
        4. 单击 Web 服务扩展文件夹。安全锁定控制台出现在右侧的框架中。
        5. 在 Web 服务扩展窗口中,右键单击 ASP.NET v4.X.XXXX,然后单击允许。

        【讨论】:

        • 我去GoDaddy发现它被配置为使用.Net Framework 2.0;我将其更改为 4.0,但我仍然遇到同样的问题。
        • 你是否重启过你的iis服务器服务
        【解决方案5】:

        -转到 IIS。 -默认网站->您的应用程序目录->高级设置->应用程序池->设置您的版本(例如 ASP.NET v4.0) - 刷新您的应用程序目录并浏览它。 完成了。

        【讨论】:

        • 这是完美的答案
        猜你喜欢
        • 2011-09-15
        • 1970-01-01
        • 1970-01-01
        • 2019-12-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多