1

在继续学习和使用 ServiceStack 的过程中,我尝试使用 ac#/WPF 应用程序来使用 hello 服务。

我已经完成了使用 NuGet 安装所需文件的预期步骤:

PM> install-package servicestack.common

我相信我已经导入了正确的命名空间:

using ServiceStack.Common;
using ServiceStack.Common.ServiceClient.Web;

然而,当我尝试按照我在 Stack 和 Github 上找到的示例进行操作时,VS10 报告找不到类型或命名空间。

var client = new JsonServiceClient("http://172.16.0.15/");

我也无法使用我认为是完全限定名称的名称创建此对象:

var client = new ServiceStack.ServiceClient.web.JsonServiceClient . . . 

为了使用这个类,是否必须安装另一个包或另一个引用?

更新:

Darin 建议的完全限定类型似乎并没有解决问题:

var client = new ServiceStack.ServiceClient.Web.JsonServiceClient("http://172.16.0.15/");

我仍然得到 VS10 报告:

"The type or namespace name 'ServiceClient' does not exist in the namespace 'ServiceStack'.... "
4

1 回答 1

6

正确的命名空间是:

using ServiceStack.ServiceClient.Web;

它不是:

ServiceStack.Common

它不是:

ServiceStack.Common.ServiceClient.Web

它不是:

ServiceStack.ServiceClient.web

因此,要么使用 using 关键字将正确的命名空间纳入范围,要么完全限定类型:

var client = new ServiceStack.ServiceClient.Web.JsonServiceClient("http://172.16.0.15/");
于 2013-09-18T21:54:44.253 回答