I have a WinForm
s project that uses EntityFramework 6.1.2-beta
with .NET4
, it worked fine, till I decided to replace EF
assemblies with their source codes, for some tracing goals, so I removed EntityFramework.dll
and EntityFramework.SqlServer.dll
from my project references and get their source codes from CodePlex and add them to my solution.
I changed these new project configuration to DebugNet40
(because my project works with .NET 4
, but EntityFramework
and EntityFramework.SqlServer
projects work with .NET 4.5
).
It compile successfully, but now when I want to run my project I get following error:
An unhandled exception of type 'System.IO.FileLoadException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll
Additional information: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
It is my app.config
file:
<?xml version="1.0" encoding="utf-8"?>
<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>
<entityFramework>
<defaultConnectionFactory
type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory,
EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices,
EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="ERPContext"
connectionString="Data Source=.;Initial Catalog=MyDb;
Persist Security Info=True;User ID=sa;password=*****"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I removed PublicKeyToken=b77a5c561934e089"
from app.config
too, but the problem exists yet.
Is there any Idea?
The Entity Framework source code is configured to produce delay-signed assemblies (which means they're marked as "should be signed in the future with the official key"). The official instructions at Entity Framework's GitHub page show how to disable strong name validation (run the EnableSkipStrongNames
task: build /t:EnableSkipStrongNames
), so that you can use the delay-signed assemblies without anyone having to release their private key. This is sufficient for development systems.
If you intend to release a product relying on your custom-built modified Entity Framework DLLs, you should generate a new key, and modify the EF source code to use that new key.
You can right click the project in Visual Studio solution explorer, and Signing on the left and uncheck sign assembly. In your web config you will also need to remove the public key token.
User contributions licensed under CC BY-SA 3.0