简体   繁体   English

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

[英]Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. manifest definition does not match the assembly reference.

I am trying to add newtonsoft.json to my project so i use this command to do that : 我正在尝试将newtonsoft.json添加到我的项目中,所以我使用此命令来做到这一点:

install-package newtonsoft.json
Successfully installed 'Newtonsoft.Json 6.0.8'.
Successfully added 'Newtonsoft.Json 6.0.8' to UI

.

So every things work fine and the reference added to my project and this part of code is added to webconfig 因此,一切正常,并将引用添加到我的项目中,并将这部分代码添加到webconfig

<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>

But when i run the project i got this error : 但是当我运行该项目时,出现此错误:

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)

the stack trace: 堆栈跟踪:

[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.0.8, 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.0.8, 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) +521

[HttpException (0x80004005): Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.8, 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) +9950728
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Two reasons for this to happen: 发生这种情况的两个原因:

  1. You debug/release folder still has outdated dll files. 您的debug/release文件夹仍然具有过时的dll文件。 Try to delete the content and build your application again. 尝试删除内容并再次构建您的应用程序。
  2. One of the packages on your solution is referencing to the wrong version of "Newtonsoft.Json" , double check if there's a reference there. 解决方案中的一个软件包引用的是错误版本的"Newtonsoft.Json" ,请仔细检查那里是否有引用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集XXX或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配 - Could not load file or assembly XXX or one of its dependencies. The located assembly's manifest definition does not match the assembly reference 无法加载文件或程序集“WebGrease”的依赖项之一。 定位的程序集的清单定义与程序集引用不匹配 - Could not load file or assembly 'WebGrease' one of its dependencies. The located assembly's manifest definition does not match the assembly reference 无法加载文件或程序集或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配 - Could not load file or assembly or one of its dependencies. The located assembly's manifest definition does not match the assembly reference 无法加载文件或程序集“System.Web.Mvc”或其依赖项之一。 定位的程序集的清单定义与程序集不匹配 - Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly 无法加载文件或程序集“Newtonsoft.Json”或其依赖项之一 - Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies 无法加载文件或程序集“ Newtonsoft.Json”或其依赖项之一? - Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies? 无法加载文件或程序集“AjaxControlToolkit”或其依赖项之一。 该模块应该包含一个程序集清单 - Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The module was expected to contain an assembly manifest 无法加载文件或程序集“ Newtonsoft.Json” - Could not load file or assembly 'Newtonsoft.Json' 无法加载文件或程序集“newtonsoft.json” - could not load file or assembly 'newtonsoft.json' 无法加载文件或程序集或其依赖项之一。 拒绝访问 - Could not load file or assembly or one of its dependencies. Access is denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM