2
votes

I have a Windows app which I developed with Entity Framework and a code-first approach. It's working perfectly on my own computer. But when I try to deploy the app to a client who has SQL Server installed, it throws the following error. What am I missing here?

System.BadImageFormatException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The module was expected to contain an assembly manifest.
File name: 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' at BLL.BLMasters.BLCompany..ctor()

Here is my app.config file:

<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>

enter image description here

1

1 Answers

0
votes

Can you please check if the project properties of all your projects are set to correct target platform?

Goto your project properties → Build → Target Platform.

Check this is set to either of the values for all your projects: x86, x64, Any CPU.

Try selecting "Any CPU" for all projects in your solution and then deploy it to client machine and check.

This error generally occurs when you have different CPU architecture then the compiled version of the target machine. Selecting Any CPU generally solves the issue.