gpt4 book ai didi

json.net - 发布版本中 PostSharp 中的 AssemblyLoadException

转载 作者:行者123 更新时间:2023-12-02 08:31:58 30 4
gpt4 key购买 nike

我有几个项目都包含 json.net 6.0.3 NuGet 包。当我添加时:

using Newtonsoft.Json;

构建时出现以下错误:

1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: Unhandled exception (3.1.48.0, 32 bit, CLR 4.5, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed'. [Version mismatch] 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: ============ PostSharp Assembly Loading Log =================== 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Finding the assembly with binding identity 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed'. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Found file 'F:\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll' with identity 'newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed, processorarchitecture=msil'. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Reference mismatch for 'F:\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll' [VersionMismatch]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\ProgramData\PostSharp\3.1.48\bin.Release\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\ProgramData\PostSharp\3.1.48\bin.Release\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\ProgramData\PostSharp\3.1.48\bin.Release\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Found file 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.dll' with identity 'newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed, processorarchitecture=msil'. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Reference mismatch for 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.dll' [VersionMismatch]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\bin\release\TwinkyTalk\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\TwinkyTalk\obj\Release\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\TwinkyTalk\obj\Release\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'F:\TwinkyTalk\obj\Release\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\Newtonsoft.Json.exe' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\Newtonsoft.Json.dll' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\Newtonsoft.Json.winmd' because this directory was explicitly added to the search path [File Not Found]. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Looking in GAC for Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=x86. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Looking in GAC for Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=msil. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: Looking in GAC for Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: LOG: The assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed' was not found. 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: =============================================================== 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.CodeModel.Domain.GetAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.CodeModel.AssemblyRefDeclaration.^5YpB0scd(BindingOptions _0) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^SgrhoGlQ(AssemblyRefDeclaration _0) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^+GwnKh4ZYHu3() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase) 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.Execute() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.ExecuteProjects() 1>F:\TwinkyTalk\TwinkyTalk.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).

我无法在项目中找到对“'newtonsoft.json,version=4.5.0.0”的任何引用,不确定为什么要查找它。

我尝试将“Build Host”PostSharp 项目属性设置为托管,但仍然遇到相同的异常。

最佳答案

当某些第 3 方库引用旧版本的程序集(在本例中为 Newtonsoft.Json)时,通常会发生这种情况。通过在 web.config/app.config 文件中指定绑定(bind)重定向来解决该问题。

<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0"/>
</dependentAssembly>

但是,您还需要告诉 PostSharp 到哪里寻找绑定(bind)重定向配置。您可以通过在 *.csproj 文件中设置 PostSharpHostConfigurationFile 属性来执行此操作:

<PropertyGroup>
<PostSharpHostConfigurationFile>web.config</PostSharpHostConfigurationFile>
</PropertyGroup>

关于 SO ( PostSharp AssemblyLoadException Autofac ) 还有一个类似的问题,还有一个 relevant blog post .

关于json.net - 发布版本中 PostSharp 中的 AssemblyLoadException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25798212/

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