首页 > 解决方案 > VSTS 负载测试无法找到程序集

问题描述

如果在本地运行,我已经编写了可以正常工作的负载测试。但是,当它们被配置为在云中运行时。我收到以下错误

无法加载文件或程序集 Newtonsoft.json 6.0.0 ...

我正在使用 Visual Studio 2017 15.7.4

目前我在项目中指的是 newtonsoft.json 11.0.2,这是我的 package.config 文件。

  <?xml version="1.0" encoding="utf-8"?>
   <packages>
    <package id="Dapper" version="1.50.5" targetFramework="net461" />
   <package id="Microsoft.AspNet.WebApi.Client" version="5.2.6" 
     targetFramework="net461" />
    <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" 
      />
      <package id="System.Security.Cryptography.Algorithms" version="4.3.1" 
      targetFramework="net461" />
       <package id="System.Security.Cryptography.Encoding" version="4.3.0" 
      targetFramework="net461" />
         <package id="System.Security.Cryptography.Primitives" 
           version="4.3.0" targetFramework="net461" />
          <package id="System.Security.Cryptography.X509Certificates" 
           version="4.3.2" targetFramework="net461" />
          </packages>

这里还有安装 nuget 包后默认在 app.config 中添加的程序集绑定。

 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
  <runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" 
  culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" 
      culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" 
          culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" 
       publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
  </dependentAssembly>
   </assemblyBinding>
   </runtime>
    </configuration>

所有引用也都标记为“CopyLocal”为真。

不知道是什么原因造成的。任何线索都会很棒。

标签: visual-studiobindingazure-devopsload-testing

解决方案


对于遇到此问题的任何人。这很奇怪,但看起来像。

System.Net.Http.Formatting(使用 Microsoft.AspNet.WebAPI.Client 5.2.6 安装)

和 Newtonsoft.Json(11.0.2) 彼此不兼容。(自行部署到云时)

当我使用 HttpClient.PostAsJsonAsync() 时,我的代码被破坏了

我只是最终删除了 System.Net.Http.Formatting dll,并使用 httpclient.PostAsync 使用了更长版本的代码,现在它似乎可以正常工作了!


推荐阅读