I tried to update my project to .NET Standard 2.0 and during testing I got catch an exception:
System.IO.FileLoadException: 'Could not load file or assembly "System.ValueTuple, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" or one of its dependencies. The definition of the assembly manifest found does not match the reference to the assembly.
This is assambly exists in package.config and exists on the package's folder. I tried some versions of System.ValueTuple package, result is one.
Why the version of dependencies «0.0.0.0»?
Does anyone have an idea about the problem?
VS 2017 Preview, UnitTestApp, .NET Framework 4.7.
In the unit test app I create EF model (Microsoft.EntityFrameworkCore, Microsoft.EntityFrameworkCore.SqlServer 2.0.0-preview2-final, it needs in .NET Standard app). The Unit test method - insert into table some rows using EF db model, and call 'savechanges', after that throw this exception.
When I used EntityFrameworkCore 1.1.2 (dll with EF model - Standard 1.4, unit test Framework 4.6.2) - this test worked well.
I solved this problem by enabling Automatic Binding Redirection in my .NET Framework 4.7 project (that references .NET Standard 2.0 library). Binding redirection can be enabled by manually editing project's .csproj
file and addind following snippet a child of Project
element:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Visual Studio then during build generates neccessary assembly redirections to project's app.config
, similar to this:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
</assemblyBinding>
allowing correct assembly to be loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With