zoukankan      html  css  js  c++  java
  • 找到的程序集清单定义与程序集引用不匹配

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


    未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

    说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

    异常详细信息: System.IO.FileLoadException: 未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

    程序集加载跟踪: 下列信息有助于确定程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”未能加载的原因。

    警告: 程序集绑定日志记录被关闭。
    要启用程序集绑定失败日志记录,请将注册表值 [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD)设置为 1。
    注意: 会有一些与程序集绑定失败日志记录关联的性能损失。
    要关闭此功能,请移除注册表值 [HKLMSoftwareMicrosoftFusion!EnableLog]。
    

    可是小猪不知道是啥时候引用了该死的这个4.5.0.0版本啊!!

    这可折腾死小猪了!!不知道是何种原因,各种百度谷歌,最后还是看到老外的一个解释:

     

    引用:
    It's not clear what the relationships of the projects are, or when this error is occuring, but here's a guess. You have 3 projects the facebook project (refs 4.0.0.0 version), twitter project (refs 4.0.3.0 version), and a main project that refs both of those projects. You may be able to build this solution, but when you run the assembly binding will fail. Why? because the default behavior is to copy assemblies locally before running. What happens is that the first project to build copies to bin (say twitter) then the second project builds (facebook), then main. However, at the end of this the 4.0.0.0 version is sitting bin folder. When you run, as soon as you invoke something from twitter that tries to use the problem assembly the bind fails because it longer has access to the 4.0.3.0 version of the assembly. There are a couple of ways around this. One is register both assemblies in the GAC. If that isn't doable then look into assembly binding redirection in your config file. Another is to register for theAssemblyResolve event and load the assembly programmatically.

    然后小猪按照其大概的方法增加了这么一句:

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>

    OK了。这真是个蛋疼的下午!!

  • 相关阅读:
    剑指offer4:重建二叉树(后序遍历)
    剑指offer3:从尾到头打印链表每个节点的值
    剑指offer2:C++实现的替换空格(字符中的空格替换为“%20”)
    tp5系统变量输出(可以用来传递搜索的参数)
    Ajax实现文件上传的临时垃圾文件回收策略
    php获取当天的开始时间和结束时间
    Think PHP递归获取所有的子分类的ID (删除当前及子分类)
    tp查找某字段,排除某字段,不用一次写那么多
    git-查看历史版本及回滚版本
    dedecms目录结构,非常全
  • 原文地址:https://www.cnblogs.com/smallerpig/p/3646211.html
Copyright © 2011-2022 走看看