当前位置: 首页 > 知识库问答 >
问题:

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

谭绍晖
2023-03-14

搜索后我尝试过的事情:

>

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

编辑我的。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>

在我的电脑上搜索每一个Newtonsoft。Json。dll并删除每一个非6.0。1版本并删除我的临时文件夹的内容

修复/重新安装Nuget管理器控制台中的包

它在构建时成功,但在访问站点时出错。

编辑

好的,然后我试着像每个nuget软件包一样重新安装,它似乎又添加了newtonsoft的4.5版本。json。dll,但我得到了相同的错误。我的项目的目标是。净额4.5。1这是我现在得到的堆栈跟踪:

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

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

描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪,了解有关错误的详细信息以及错误在代码中的起源。

异常详细信息:系统。木卫一。FileLoadException:无法加载文件或程序集Newtonsoft。Json或其依赖项之一。定位的程序集清单定义与程序集引用不匹配。(HRESULT的异常:0x8013100

源错误:

在执行当前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

共有3个答案

郑胡媚
2023-03-14

在确保我的计算机在所有位置都有相同的版本并且我的项目都指向相同的引用路径之后,我尝试了以下步骤。我还确保旧版本的绑定是他们的,并绑定到我拥有的当前版本的dll。

我在一个有严格框架的环境中工作,框架团队经常用不同的dll破坏版本控制。

我如何修复这个问题是在Visual Studio(2013)中运行包管理器控制台。从那里,我运行了以下命令:

update-package Newtonsoft.Json -reinstall

然后

update-package Newtonsoft.Json

这已经完成并更新了我所有的配置文件和相关的项目文件。强制它们都使用相同版本的dll。在再次更新以获取最新版本之前,它最初是版本4.5。

东方涛
2023-03-14

我正在使用Newtonsoft。Json v6.0.3,但这是我在Web.config文件中必须做的:

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

请注意,即使我使用的是6.0。3,我必须输入newVersion=“6.0.0.0”

在我的包裹里。我拥有的配置文件:

<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
汪信鸥
2023-03-14

为了解决这个问题,我通过运行以下命令并检查结果来确保我的所有项目使用相同的版本:

update-package Newtonsoft.Json -reinstall

最后,我从我的网站上删除了以下内容。配置:

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

如果您想确保所有的Newtonsoft。Json包的版本相同,您可以这样指定版本:

update-package Newtonsoft.Json -version 6.0.0 -reinstall
 类似资料:
  • 问题内容: 搜索后我尝试过的事情: 在Web.Config中,对旧版本进行绑定: 问题答案: 好的,我想我现在可以开始工作了。我删除了机器上所有不是我可以找到的最新版本的Newtonsoft.Json.dll,确保在NuGet中拥有最新版本,并进行构建,并确保它是bin文件夹中的最新版本,并且我将更改保留在web.config和.csproj中。现在,我遇到另一个错误,因此它必须正在工作。

  • 我在我的网站(web应用程序)中使用了Umbraco 4.11.6。我的网站在localhost上运行(在Visual studio 2012和IIS(v7)上测试过),但是当我在互联网上运行时,出现了一个错误。错误是: 程序集加载跟踪:以下信息有助于确定程序集“System.Web”的原因。无法加载“剃刀”。 WRN:程序集绑定日志记录已关闭。若要启用程序集绑定失败日志记录,请设置注册表值 [H

  • 我在我的应用程序中使用MVC 5,WCF和Unity框架。 当我运行WCF服务时,我收到以下错误: 我已添加System.Web.WebPages。WCF项目中的Razor,版本=3.0.0.0,仍然存在相同的错误。 有人知道如何解决这个错误吗?

  • 我尝试将两个 ASP.NET Web 项目(一个 Facebook 应用程序和一个机器人)部署到同一个 Azure 网站,但在我部署了它们之后,我收到了: 无法加载文件或程序集“System.Web”。Mvc’或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT异常:0x80131040) 我不确定我能做什么,除了从头开始并将两个项目合并成一个项目(不可取)重新发布。到目前为

  • 问题内容: 我正在使用sharepoint2010。我创建了一个简单的可视化Web部件,其中包含一个文本框,并向其中添加了calendarextender。我已添加为参考。但是,当我部署到SharePoint网站时,它给了我以下错误。 “解析器错误”消息: 无法加载文件或程序集“ AjaxControlToolkit”或其依赖项之一。该系统找不到指定的文件。 源错误: 第3行:<%@ Regist

  • 我已将.NET WebAPI应用程序(根据.NET 4.5.2编译并在本地运行)部署到Azure应用程序服务中。 这里抛出的错误是 无法加载文件或程序集“System. Web. Mvc,版本=4.0.40804.0,文化=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 我已检查应用服务的 目录中的 System.W