无法从程序集'RestSharp,Version = 105.1.0.0加载'RestSharp.Authenticators.HttpBasicAuthenticator'类型

Aji*_*sha 7 twilio restsharp

我使用过运行的MVC Web应用程序ASP.NET Framework version 4.5.1.我做了nopcommercePlugin.我正在将版本3.4升级到3.5

更新后,我收到以下错误:

System.TypeLoadException: Could not load type
 'RestSharp.HttpBasicAuthenticator' from assembly 'RestSharp,
 Version=105.2.1.0, Culture=neutral, PublicKeyToken=null'.
Run Code Online (Sandbox Code Playgroud)

我Twilio用来发送短信:

using Twilio;

public bool MethodName(string FromNumber, string ToNumber, string URL, string code = "")
        {

            if (code == "")
            {
                //URL = URL.Replace(" ", "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20");
                URL = URL.Replace(" ", "%20");

            }
            else
            {
                URL = URL + code + " we repeat your code is : " + code;
                URL = URL.Replace(" ", "%20");
            }

            string AccountSid = _SMSProviderSettings.SMSGatewayTwillioAccountSID;
            string AuthToken = _SMSProviderSettings.SMSGatewayTwillioAccountAuthToken;

            var twilio = new TwilioRestClient(AccountSid, AuthToken);

            var options = new CallOptions();
            var twimal = new Twilio.TwiML.TwilioResponse();
            twimal.Pause(5);

            options.To = ToNumber;

            options.Url = URL;
            options.From = FromNumber;
            options.Method = "GET";
            var call = twilio.InitiateOutboundCall(options);
            if (call != null)
            {
                if (call.RestException == null)
                    return true;
            }
            //error log entry in system log
            _logger.InsertLog(LogLevel.Error, call.RestException.Message, call.RestException.Message + " For more detail click here " + call.RestException.MoreInfo);
            return false;
        }
Run Code Online (Sandbox Code Playgroud)

已安装的版本是:

  • Twilio.4.0.5
  • Twilio.TwiML.3.3.6
  • Twilio.Mvc.3.1.15
  • RestSharp.105.1.0

我在2015年8月18日(8天前)发现了一个类似的问题,并且在讨论Twilio Nuget报告的Alpha版本的页面上也有一些讨论.

如果我使用RestShrap 105.2.2版本,则生成这些错误 在此输入图像描述

谁能告诉我应该使用哪些版本选项?

Mar*_*ona 8

Twilio开发者传道者在这里.

RestSharp上周已更新至版本105.2.2.由于HttpBasicAuthenticator被移动到不同的命名空间,导致Twilio库开始失败.

Twilio Library已更新至4.0.5版,现在可与RestSharp版本105.2.2一起使用.该软件包文件也已更新为使用该版本.

简而言之,您需要做的就是通过运行Nuget Package Manager或通过Package Manager Console将RestSharp更新到版本105.2.2:

Install-Package RestSharp
Run Code Online (Sandbox Code Playgroud)


Aji*_*sha -1

通过程序包管理器控制台安装 RestSharp 程序包时,在 RestSharp 文件夹中有多个文件夹,选择net452-client并安装 RestSharp dll。

之后我的错误就解决了。