• Newtonsoft.Json文件错误


    今天,在一个项目中使用signalR,由于项目框架是.net 4.0,所以用signalR1.0版本,signalR使用需要newtonsoft.Json文件,它把原  newtonsoft.Json文件覆盖了,所以程序运行时出现如下错误:

      “  未能加载文件或程序集“Newtonsoft.Json”或它的某一个依赖项。无法验证强名称签名。此程序集可能已被篡改,或者已被延迟签名,但没有用正确的私钥进行完全签名。 (异常来自 HRESULT:0x80131045) ”

    为了以防多方使用newtonsoft.json文件出现不同的版本冲突,所以该项目里对其做了处理,在web.config里,加入如下条件:

    <runtime>
                <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                    <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>
                    <dependentAssembly>
                        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
                        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
                    </dependentAssembly>
                    <dependentAssembly>
                        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
                    </dependentAssembly>
                    <dependentAssembly>
                        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
                        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
                    </dependentAssembly>
    
                    <dependentAssembly>
                        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
                    </dependentAssembly>
                </assemblyBinding>
            </runtime>
    View Code

    <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>该节点表面自动将所有老版本绑定为6.0版本。

    所以将新加载的newtonsoft.json删掉,重新引用原6.0版本的。

    但由于之前已经进行了编译,所以运行后那个错误还存在,我的解决办法就是在系统盘里找到Temporary ASP.NET Files文件,删掉,重新编译就OK

  • 相关阅读:
    测试AtomicInteger的可见性、有序性、原子性
    java实现hssf导出excel文件及自定义选择路径工具类
    map转换成com.google.gson.JsonObject
    String[]转List<String>
    classLoader打破双亲委托机制
    类加载器的加密解密
    自定义类加载器和父委托机制
    java中获取项目路径
    JVM内置三大类加载器详细介绍
    初识继承和多态
  • 原文地址:https://www.cnblogs.com/beliee/p/3880526.html
Copyright © 2020-2023  润新知