无法加载文件或程序集“ System.ValueTuple,版本= 0.0.0.0&”;或其依赖项之一 [英] Could not load file or assembly "System.ValueTuple, Version=0.0.0.0" or one of its dependencies

查看:1689
本文介绍了无法加载文件或程序集“ System.ValueTuple,版本= 0.0.0.0&”;或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将项目更新为.NET Standard 2.0,并且在测试过程中捕获了一个异常:

I tried to update my project to .NET Standard 2.0 and during testing I got catch an exception:


System.IO.FileLoadException :'无法加载文件或程序集 System.ValueTuple,版本= 0.0.0.0,区域性=中性,PublicKeyToken = cc7b13ffcd2ddd51或其依赖项之一。找到的程序集清单的定义与对该程序集的引用不匹配。

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.

这通常存在于package.config $ b $中b
,它位于软件包的文件夹中。我尝试了某些版本的System.ValueTuple包,结果是一个。

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.

为什么依赖项版本为 0.0.0.0»?

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。

VS 2017 Preview, UnitTestApp, .NET Framework 4.7.

在单元测试应用程序中,我创建EF模型(Microsoft.EntityFrameworkCore,Microsoft.EntityFrameworkCore.SqlServer 2.0.0-preview2-final,在.NET Standard应用程序中需要)。
单元测试方法-使用EF db模型将某些行插入表中,并在引发此异常后调用 savechanges。

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.

当我使用EntityFrameworkCore时1.1.2(带有EF模型的dll-标准1.4,单元测试框架4.6.2)-此测试运行良好。

When I used EntityFrameworkCore 1.1.2 (dll with EF model - Standard 1.4, unit test Framework 4.6.2) - this test worked well.

推荐答案

我通过启用自动绑定重定向在我的.NET Framework 4.7项目(引用.NET Standard 2.0库)中。可以通过手动编辑项目的 .csproj 文件并在片段 Project 的子元素之后添加addind来启用绑定重定向:

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然后在生成过程中生成必要的程序集重定向到项目的 app.config ,类似于此:

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.

这篇关于无法加载文件或程序集“ System.ValueTuple,版本= 0.0.0.0&”;或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆