gpt4 book ai didi

.net-standard - 无法加载文件或程序集 "System.ValueTuple, Version=0.0.0.0"或其依赖项之一

转载 作者:行者123 更新时间:2023-12-03 11:56:40 25 4
gpt4 key购买 nike

我试图将我的项目更新到 .NET Standard 2.0,在测试过程中我发现了一个异常:

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 中存在

并且存在于包的文件夹中。我尝试了一些版本的 System.ValueTuple 包,结果是一个。

为什么依赖版本«0.0.0.0»?

有人知道这个问题吗?

VS 2017 预览版,UnitTestApp,.NET Framework 4.7。

在单元测试应用程序中,我创建了 EF 模型(Microsoft.EntityFrameworkCore、Microsoft.EntityFrameworkCore.SqlServer 2.0.0-preview2-final,它需要在 .NET Standard 应用程序中)。
单元测试方法 - 使用 EF db 模型将一些行插入表中,然后调用“savechanges”,然后抛出此异常。

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

最佳答案

我通过启用 Automatic Binding Redirection 解决了这个问题在我的 .NET Framework 4.7 项目(引用 .NET Standard 2.0 库)中。可以通过手动编辑项目的 .csproj 来启用绑定(bind)重定向。文件并添加以下片段 Project 的子项元素:

<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

Visual Studio 然后在构建期间生成到项目的 app.config 的必要程序集重定向。 ,类似这样:
<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>

允许加载正确的程序集。

关于.net-standard - 无法加载文件或程序集 "System.ValueTuple, Version=0.0.0.0"或其依赖项之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44844798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com