Service Stack/MVC: “AppHostBase.Instance has already been set” error - but can't understand why/how to prevent

StackOverflow https://stackoverflow.com/questions/8954622

  •  12-11-2019
  •  | 
  •  

Вопрос

I'm trying to implement ServiceStack into my MVC3 project, and am following the tutorial at: http://www.servicestack.net/ServiceStack.Hello/

My Global.asax.cs now looks like:

    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();

        }
    }
}

... as per the instructions.

However, when I call the Init() method, I get the exception:

InvalidDataException: AppHostBase.Instance has already been set

Googling around for this provides no help, except the source code at http://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Common/ServiceStack.WebHost.Endpoints/AppHostBase.cs?r=1322

Looking at this, somehow, the Instance is being set. But how?

What could be causing this?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top