2

SMS ゲートウェイ サービスを必要とするアプリを開発しています。当社はPlivoサービスを利用しています。サンプル コードをたどってみました。ソリューションをビルドしようとしたときに、次の 2 つのエラーが発生しました。

エラー 1:The type 'RestSharp.IRestResponse'1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'RestSharp, Version=105.1.0.0, Culture=neutral, PublicKeyToken=null'

エラー 2:Cannot implicitly convert type 'RestSharp.IRestResponse'1<Plivo.API.MessageResponse>' to 'RestSharp.IRestResponse<Plivo.API.MessageResponse>'

NuGet を介して Plivo および RestSharp API をインストールし、ソリューション エクスプローラーで dll を確認できるため、これらのエラーの理由がわかりません。2 番目のエラーは、奇妙な type のため、さらに混乱します'RestSharp.IRestResponse'1

誰かがこの問題について私にアドバイスできるなら、私はとても感謝しています.

私のソースコード:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using Plivo.API;
using System.Reflection;

namespace SMSGatewayTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string auth_id = "XXX";     // obtained from Plivo account dashboard
            string auth_token = "YYY";  // obtained from Plivo account dashboard

            RestAPI plivo = new RestAPI(auth_id, auth_token);

            IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() 
            {
                { "src", "37061549145" }, 
                { "dst", "37068824525" }, 
                { "text", "Hi, text from Plivo." }, 
            });


            if (resp.Data != null)
            {
                PropertyInfo[] proplist = resp.Data.GetType().GetProperties();
                foreach (PropertyInfo property in proplist)
                Console.WriteLine("{0}: {1}", property.Name, property.GetValue(resp.Data, null));
            }
            else
            {
                Console.WriteLine(resp.ErrorMessage);
            }
        }
    }
}

PS 質問を書いているときに何かを見逃した場合は、質問してください。SMS ゲートウェイを使用するのは初めての経験です。

4

1 に答える 1

2

それで、数時間の調査の後、私はなんとか事件を見つけることができました. NuGet の自動インストールでは、RestSharp バージョン 100.0.0 がインストールされるようで、105.1.0.0 が必要です。解決策は、NuGet コンソールに次のように入力することでした: Install-Package RestSharp -Version 105.0.1

于 2015-08-03T14:36:09.383 に答える