缺少ServiceStack的DLL

时间:2013-09-20 19:20:03

标签: c# dll servicestack

我有一个基于code taken from here的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,以便我可以完成构建吗?

1 个答案:

答案 0 :(得分:3)

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

您还需要此声明:

using ServiceStack.ServiceClient.Web;