gpt4 book ai didi

c# - 发现不同版本的 "System.Runtime.CompilerServices.Unsafe"冲突无法解决

转载 作者:行者123 更新时间:2023-12-03 16:20:10 27 4
gpt4 key购买 nike

这似乎是许多类似问题之一,但我在其他问题中找不到解决方案。
我将直接跳转到二进制日志:
enter image description here
这是 ResolveAssemblyReference 下的相应子树任务:

There was a conflict between "System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"System.Runtime.CompilerServices.Unsafe, Version = 4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "System.Runtime.CompilerServices.Unsafe, Version = 4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\mkharitonov\.nuget\packages\system.runtime.compilerservices.unsafe\4.5.2\ref\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll].
C:\Users\mkharitonov\.nuget\packages\system.runtime.compilerservices.unsafe\4.5.2\ref\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
Project file item includes which caused reference "C:\Users\mkharitonov\.nuget\packages\system.runtime.compilerservices.unsafe\4.5.2\ref\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll".
C:\Users\mkharitonov\.nuget\packages\system.runtime.compilerservices.unsafe\4.5.2\ref\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
C:\Users\mkharitonov\.nuget\packages\microsoft.extensions.primitives\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll
Project file item includes which caused reference "C:\Users\mkharitonov\.nuget\packages\microsoft.extensions.primitives\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll".
C:\Users\mkharitonov\.nuget\packages\microsoft.extensions.primitives\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll
C:\Users\mkharitonov\.nuget\packages\microsoft.extensions.caching.abstractions\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll
xyz.Common
C:\xyz\tip\bin.link\xyz.Web.Framework.dll
C:\xyz\tip\bin.link\xyz.Web.Platform.dll
AccrualEngine
DataProcessor
xyz.BusinessAPI.Core
xyz.DataManager
DataSvc
xyz.Data
xyz.HtmlPlatform
xyz.BusinessAPI
DeviceServices
GrossPayEngineDataProvider
MultiApprovalProcessor
Payroll.Core.Data
PunchStatusReconciliationEngine
RateEngine2
RateEngineDataProviderServer
RuleEngine
RuleEngineDataProvider
RuleEngineHelper
SharpTop.Common.Security.MemberSession
SharpTop.DB.DL
WorkTimeCalculationEngine
C:\Users\mkharitonov\.nuget\packages\microsoft.extensions.caching.memory\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Memory.dll
C:\Users\mkharitonov\.nuget\packages\microsoft.extensions.options\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll
C:\Users\mkharitonov\.nuget\packages\system.memory\4.5.3\lib\netstandard2.0\System.Memory.dll
Project file item includes which caused reference "C:\Users\mkharitonov\.nuget\packages\system.memory\4.5.3\lib\netstandard2.0\System.Memory.dll".
C:\Users\mkharitonov\.nuget\packages\system.memory\4.5.3\lib\netstandard2.0\System.Memory.dll
C:\Users\mkharitonov\.nuget\packages\system.diagnostics.diagnosticsource\4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll
C:\Users\mkharitonov\.nuget\packages\microsoft.applicationinsights\2.10.0\lib\net46\Microsoft.ApplicationInsights.dll
C:\Users\mkharitonov\.nuget\packages\xyz.engine.core.common\1.0.20260.1\lib\netstandard2.0\xyz.Engine.Core.Common.dll
xyz.Common
C:\xyz\tip\bin.link\xyz.Web.Framework.dll
C:\xyz\tip\bin.link\xyz.Web.Platform.dll
AccrualEngine
DataProcessor
xyz.BusinessAPI.Core
xyz.DataManager
DataSvc
xyz.Data
xyz.HtmlPlatform
xyz.BusinessAPI
DeviceServices
GrossPayEngineDataProvider
MultiApprovalProcessor
Payroll.Core.Data
PunchStatusReconciliationEngine
RateEngine2
RateEngineDataProviderServer
RuleEngine
RuleEngineDataProvider
RuleEngineHelper
SharpTop.Common.Security.MemberSession
SharpTop.DB.DL
WorkTimeCalculationEngine
C:\xyz\tip\Tools\MSBuild\..\..\bin.link\System.Threading.Tasks.Extensions.dll
Project file item includes which caused reference "C:\xyz\tip\Tools\MSBuild\..\..\bin.link\System.Threading.Tasks.Extensions.dll".
GrossPayEngineDataProvider
C:\xyz\tip\Tools\MSBuild\..\..\bin.link\Pipelines.Sockets.Unofficial.dll
Project file item includes which caused reference "C:\xyz\tip\Tools\MSBuild\..\..\bin.link\Pipelines.Sockets.Unofficial.dll".
GrossPayEngineDataProvider
References which depend on "System.Runtime.CompilerServices.Unsafe, Version = 4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\System.Runtime.CompilerServices.Unsafe.dll].
从中我得出结论, System.Runtime.CompilerServices.Unsafe.dll 有两个版本。正在上映:
  • NuGet 包 - C:\Users\mkharitonov.nuget\packages\system.runtime.compilerservices.unsafe\4.5.2\ref\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
  • C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\System.Runtime.CompilerServices.Unsafe.dll

  • 二进制日志非常详细地显示了哪些程序集依赖于 NuGet 包,但对于第二个引用,它没有显示任何内容。这很奇怪,因为那么问题是 - 为什么首先考虑第二个版本?
    有问题的项目只是一个库,因此没有 app.config 文件。另外, AutoUnify == true所以 ResolveAssemblyReference任务应该自动解决冲突到最高版本,至少这是我对 documentation的解释.
    所以,我很困惑。我知道警告是次要的,可以忽略,但我想了解它的性质。如果显然所有依赖项都依赖于 NuGet 包,是什么原因造成的。或者该任务可能没有输出某种依赖关系,而是让我来调查依赖于 的内容。 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\System.Runtime.CompilerServices.Unsafe.dll ?
    作为记录:
  • NuGet包的汇编版本是4.0.4.1,第二个版本是4.0.6.0,所以不应该都解析到最高版本,即第二个版本吗?
  • 我的代码都没有直接引用 System.Runtime.CompilerServices.Unsafe,所以 ResolveAssemblyReference 列出的所有依赖项任务必须是可传递的。
  • 我尝试添加 应用程序配置使用绑定(bind)重定向将文件提交到有问题的项目,即使由于 AutoGenerateBindingRedirects 的存在,应该不需要这样做。属性(property)。正如我所料 - 它没有帮助。

  • 我如何确定发生了什么以及如何解决它?

    最佳答案

    我有一个更新。
    在我们这边,app.config 中有一个条目重定向到 4.0.6.0。
    我们从未见过这个问题,因为构建机器上没有 4.0.6.0。
    但是当我们将 Visual Studio 更新到最新版本时,msbuild 不知何故复制了它。

    _CopyFilesMarkedCopyLocal:
    The File will be copied from "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\System.Runtime.CompilerServices.Unsafe.dll" in "D:\agent_03\_work\21\s\Release\System.Runtime.CompilerServices.Unsafe.dll".
    一旦我们删除了配置文件中的条目,该文件就不再被复制。
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
    </dependentAssembly>
    </assemblyBinding>
    在您的 app.configs 上搜索任何特定条目。如果找不到,恐怕您需要遍历所有 nuget 依赖项,直到找到哪个需要此特定版本。
    干杯,
    马可

    关于c# - 发现不同版本的 "System.Runtime.CompilerServices.Unsafe"冲突无法解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64420099/

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