【问题标题】:VSTS load tests not able to find assemblyVSTS 负载测试无法找到程序集
【发布时间】:2018-08-01 12:08:53
【问题描述】:

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

无法加载文件或程序集 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”为真。

不确定是什么原因造成的。任何线索都会很好。

【问题讨论】:

  • 您的项目或程序集/nuget 包之一似乎仍在引用旧版本的Newtonsoft.Json nuget 包。检查您是否在解决方案中使用了该 nuget 包的不同版本,以及解决方案中每个项目的引用。
  • 这是一个独立的项目,不依赖于解决方案中的任何其他项目。
  • 该项目中的某处必须有其他依赖项仍在引用 v6.0.0
  • @MandarJogalekar 尝试卸载 Newtonsoft.Json 包,然后重新安装,看能否重现此问题。另外,尝试在另一台机器上运行你的项目(不要复制包),检查你是否会得到同样的错误。
  • 已经卸载并安装了 newtonsoft.json。它不起作用。负载测试也在云上运行,所以我的本地机器只是上传文件到那里。对吗?

标签: visual-studio binding azure-devops load-testing


【解决方案1】:

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

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,现在它似乎可以正常工作了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-11
    • 2018-05-19
    • 1970-01-01
    相关资源
    最近更新 更多