2

我有一个基于从这里获取的代码的 TestClient 应用程序。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security;
using System.Net;
using ServiceStack.Common.Web;
using ServiceStack.Logging;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;

namespace TestClient
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var client = new JsonServiceClient(); // missing assembly reference

                client.LocalHttpWebRequestFilter +=
                    delegate(HttpWebRequest request)
                    {
                        // ContentType still null at this point so we must hard code it
                        request.ContentType = ServiceStack.Common.Web.ContentType.Json;
                        request.Date = DateTime.Now;

                        var secret = "5771CC06-B86D-41A6-AB39-9CA2BA338E27";
                        var token = ApiSignature.CreateToken(request, secret);
                        request.Headers.Add(ApiCustomHttpHeaders.UserId, "1");
                        request.Headers.Add(ApiCustomHttpHeaders.Signature, token);
                    };


                var teams = client.Get<List<Team>>("http://localhost:59833/api/teams");
                foreach (var team in teams)
                {
                    Label1.Text += team.Name + "<br>";
                }
            }
            catch (WebServiceException ex) // missing assembly reference
            {
                Label1.Text = ex.Message + " : " + ex.ResponseBody;
            }
        }
    }
}

我似乎缺少以下程序集参考:

JsonServiceClient
WebServiceException

谁能告诉我在哪里可以获得这些 DLL 以便我可以完成构建?

4

1 回答 1

3

您可能缺少 ServiceStack.Common 或 ServiceStack.Interfaces。只需从 NuGet安装ServiceStack.Common 包,它就会正确添加这些引用。

你还需要这个语句:

using ServiceStack.ServiceClient.Web;
于 2013-09-20T19:24:11.077 回答