Stack de service / MVC: «AppHostBase.instance a déjà été définie» Erreur - mais je ne comprends pas pourquoi / comment empêcher

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

  •  12-11-2019
  •  | 
  •  

Question

J'essaie d'implémenter ServiceStack dans mon projet MVC3, et je suis le tutoriel à: http://www.servicestack.net/servicestack.hello/

Mon global.asax.cs ressemble maintenant:

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

        }
    }
}

... selon les instructions.

Cependant, lorsque j'appelle la méthode init (), j'obtiens l'exception:

InvaliddataException: apphostbase.instance a déjà été définie

Googler pour cela ne fournit aucune aide, à l'exception du code source à http://code.google.com/p/servicestack/source/browse/trunk/common/servicestack.common/servicestack.webhost.endpoints/apphostbase.cs?r=1322

En regardant cela, en quelque sorte, l'instance est définie. Mais comment?

Qu'est-ce qui peut causer cela?

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top