1

我只是想创建一个像 HelloWorld 这样的简单服务。但是,AppHost 正在抛出:

Method 'Add' in type 'ServiceStack.ServiceHost.ServiceRoutes' from assembly 'ServiceStack, Version=3.9.4.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

using ServiceStack.WebHost.Endpoints;
using Funq;

namespace Eagle
{
  public class Global : System.Web.HttpApplication
  {

      public class TestAppHost : AppHostBase
      {
          //Tell Service Stack the name of your application and where to find your web services
          public TestAppHost() : base("Test Web Services", typeof(TestService).Assembly) { }

          public override void Configure(Container container)
          {
              //register user-defined REST-ful urls
              Routes
                .Add<Test>("/test")
                .Add<Test>("/test/{Name}");
          }
      }


      protected void Application_Start(object sender, EventArgs e)
      {
          try
          {
              new TestAppHost().Init();
          }
          catch (Exception ex)
          {
          }
      }
  }
}
4

1 回答 1

2

Routes.Add<T>是命名空间中的扩展方法ServiceStack.ServiceInterface,为了能够使用它,您需要添加:

using ServiceStack.ServiceInterface;

我建议使用 ReSharper,它会自动解析缺失的 C# 命名空间。

于 2012-09-12T17:59:48.447 回答