繁体   English   中英

Windows 应用程序部署与 SQL 服务器数据库和实体框架错误

[英]Windows application deployment with SQL Server database and Entity Framework error

我有一个使用实体框架和代码优先方法开发的 Windows 应用程序。 它在我自己的电脑上完美运行。 但是,当我尝试将应用程序部署到安装了 SQL 服务器的客户端时,它会引发以下错误。 我在这里想念什么?

System.BadImageFormatException:无法加载文件或程序集“EntityFramework,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”或其依赖项之一。 该模块应包含程序集清单。
文件名:'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' at BLL.BLMasters.BLCompany..ctor()

这是我的app.config文件:

<configuration>
    <configSections>
        <section name="entityFramework"
                 type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                 requirePermission="false"/>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
    </startup>
    <connectionStrings>
        <add name="MyDBConnectionString" 
             providerName="System.Data.SqlClient"
             connectionString="Data Source=DESKTOP-NMSSFU8;Initial Catalog=AMSDEV;Integrated Security=True; Max Pool Size=200;" />
    </connectionStrings>
    <entityFramework>
        <providers>
            <provider invariantName="System.Data.SqlClient" 
                      type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
        </providers>
    </entityFramework>
</configuration>

在此处输入图像描述

您能否检查一下您所有项目的项目属性是否设置为正确的目标平台?

转到您的项目属性 → 构建 → 目标平台。

检查这是否设置为所有项目的任一值:x86、x64、任何 CPU。

尝试为解决方案中的所有项目选择“任何 CPU”,然后将其部署到客户端计算机并检查。

当您的 CPU 架构与目标机器的编译版本不同时,通常会发生此错误。 选择任何 CPU 通常可以解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM