小编典典

无法加载文件或程序集“ Newtonsoft.Json”或其依赖项之一。清单定义与程序集引用不匹配

json

搜索后我尝试过的事情:

  1. 在Web.Config中,对旧版本进行绑定:

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

  2. 编辑我的.csproj文件,以确保只有一个Newtonsoft参考

        <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
       <SpecificVersion>False</SpecificVersion>
       <Private>True</Private>
    </Reference>
  1. 在我的计算机上搜索每个Newtonsoft.Json.dll并删除每个非6.0.1版本并删除我的temp文件夹的内容

  2. 在nuget Manager控制台中修复/重新安装软件包

它可以成功构建,但是在转到站点时出现错误。

编辑

好的,因此我尝试像每个nuget软件包一样重新安装,似乎已添加回4.5版本的newtonsoft.json.dll,但我遇到了相同的错误。我项目的目标框架是.NET
4.5.1,这是我现在得到的堆栈跟踪:

“ /”应用程序中的服务器错误。

无法加载文件或程序集Newtonsoft.Json或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(从HRESULT异常:0x80131040

说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中起源的更多信息。

异常详细信息:System.IO.FileLoadException无法加载文件或程序集Newtonsoft.Json或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(从HRESULT异常:0x80131040

源错误:

当前Web请求的执行期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息。

程序集加载跟踪:以下信息有助于确定为什么Newtonsoft.Json无法加载程序集。

    === Pre-bind state information ===
    LOG: DisplayName = Newtonsoft.Json
    (Partial)
    WRN: Partial binding information was supplied for an assembly:
    WRN: Assembly Name: Newtonsoft.Json | Domain ID: 2
    WRN: A partial bind occurs when only part of the assembly display name is provided.
    WRN: This might result in the binder loading an incorrect assembly.
    WRN: It is recommended to provide a fully specified textual identity for the assembly,
    WRN: that consists of the simple name, version, culture, and public key token.
    WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
    LOG: Appbase = file:///c:/users/user/documents/visual studio 2013/Projects/foo/bar/
    LOG: Initial PrivatePath = c:\users\user\documents\visual studio 2013\Projects\foo\bar\bin
    Calling assembly : (Unknown).
     ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: c:\users\user\documents\visual studio 2013\Projects\foo\bar\web.config
    LOG: Using host configuration file: C:\Users\user\Documents\IISExpress\config\aspnet.config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json.DLL.
    LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json/Newtonsoft.Json.DLL.
    LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/foo/bar/bin/Newtonsoft.Json.DLL.
    LOG: Using application configuration file: c:\users\user\documents\visual studio 2013\Projects\foo\bar\web.config
    LOG: Using host configuration file: C:\Users\user\Documents\IISExpress\config\aspnet.config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Redirect found in application configuration file: 4.5.0.0 redirected to 6.0.1.0.
    LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
    LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json.DLL.
    LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json/Newtonsoft.Json.DLL.
    LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/foo/bar/bin/Newtonsoft.Json.DLL.
    WRN: Comparing the assembly name resulted in the mismatch: Major Version
    ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

堆栈跟踪:

    [FileLoadException: Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

    [FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
           System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
           System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
           System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
           System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
           System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
           System.Reflection.Assembly.Load(String assemblyString) +28
           System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

    [ConfigurationErrorsException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
           System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
           System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
           System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
            System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
           System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
           System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285
           System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
           System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

    [HttpException (0x80004005): Could not load file or assembly 'Newtonsoft.Json, Version=6.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
           System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9913572
           System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
           System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408

阅读 557

收藏
2020-07-27

共1个答案

小编典典

好的,我想我现在可以开始工作了。我删除了机器上所有不是我可以找到的最新版本的Newtonsoft.Json.dll,确保在NuGet中拥有最新版本,并进行构建,并确保它是bin文件夹中的最新版本,并且我将更改保留在web.config和.csproj中。现在,我遇到另一个错误,因此它必须正在工作。

2020-07-27