visual-studio - 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”为真。
不知道是什么原因造成的。任何线索都会很棒。
解决方案
对于遇到此问题的任何人。这很奇怪,但看起来像。
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 使用了更长版本的代码,现在它似乎可以正常工作了!
推荐阅读
- amazon-web-services - 强制执行 AWS Glue 表属性顺序
- javascript - 将帐户名称从 URL 复制到剪贴板
- multiprocessing - 如何在 autoscaler config.yaml 中为特定节点声明 CPU 数量
- oracle - 在oracle中插入特定列的数据
- json - Azure 数据工厂 - forEach - JSON 到数组错误
- c# - 将文件上传到onedrive c#核心的问题
- reactjs - 使用 props.match.params.id 渲染项目的问题
- asp.net-core - 异步方法未从剃须刀组件内执行
- android - 适用于 Android 的 Unity 插件中的本机库加载顺序
- php - Simplesamlphp IdP 登录后重定向到错误的 url