【问题标题】:How to get around RestSharp "A strongly-named assembly is required"如何绕过 RestSharp“需要一个强名称的程序集”
【发布时间】:2019-09-25 11:32:53
【问题描述】:

我将 RestSharp 用于 Dynamics 插件,这要求项目是 DLL。运行插件时收到此错误消息:

ISV 代码出现意外错误。 (ErrorType = ClientError)插件(执行)的意外异常:pluginname.PluginEntryPoint:System.IO.FileLoadException:无法加载文件或程序集'RestSharp,Version = 105.0.0.0,Culture = Neutral,PublicKeyToken = null'或一个其依赖项。需要强命名程序集。 (HRESULT 例外:0x80131044)如果您联系支持人员,请提供技术细节

我的代码使用的是 .NET Framework 4.6.2,RestSharp 版本是 106.6.10

这是我要运行的代码:

var body = " {\"data\": [{ \"name\": " + name + ", \"parent_id\": \"0\", \"short_code\": " + shortcode + ", \"billable\": \"yes\",  \"assigned_to_all\": \"yes\", \"billable_rate\": \"37.50\"}]}";
var client = new RestClient("https://rest.tsheets.com/api/v1/jobcodes");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");//authorisation token
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
return true;

我怎样才能解决这个问题?

【问题讨论】:

  • 请提供您尝试运行的代码
  • 我已经更新了帖子以包含代码,它用于 TSheets 集成
  • 如果解决方案中有其他项目,请确保所有项目使用相同版本的RestSharp dll或包。
  • 其他项目根本不使用RestSharp

标签: c# rest plugins microsoft-dynamics restsharp


【解决方案1】:

在您的 app.config 或 web.config 中,找到 RestSharp 所在的行。像这样的:

<dependentAssembly>
    <assemblyIdentity name="Resrsharp.." publicKeyToken="35bf3856bd364e31" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>

检查此行的版本号和实际的 DLL 版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多