我正在尝试将 ServiceStack 实现到我的 MVC3 项目中,并且正在遵循以下教程:http ://www.servicestack.net/ServiceStack.Hello/
我的 Global.asax.cs 现在看起来像:
public class MvcApplication : System.Web.HttpApplication
{
public class Hello
{
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
public class HelloService : IService<Hello>
{
public object Execute(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name };
}
}
public class HelloAppHost : AppHostBase
{
//Tell Service Stack the name of your application and where to find your web services
public HelloAppHost() : base("Hello Web Services", typeof(HelloService).Assembly) { }
public override void Configure(Container container)
{
//register user-defined REST-ful urls
Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name}");
}
}
protected void Application_Start()
{
new HelloAppHost().Init();
}
}
}
...按照说明。
但是,当我调用 Init() 方法时,我得到了异常:
InvalidDataException:已设置 AppHostBase.Instance
看着这个,不知何故,正在设置实例。但是怎么做?
这可能是什么原因造成的?