4

I am following the service stack "Hello World" tutorial from http://www.servicestack.net/ServiceStack.Hello/ . But when I am trying to start the asp.net application it says "Value can't be null. Parameter Name: EndpointHost.Config".

The full exception text is:

[ArgumentNullException: Der Wert darf nicht NULL sein.
Parametername: EndpointHost.Config]

[ConfigurationErrorsException: ServiceStack: AppHost does not exist or has not been initialized. Make sure you have created an AppHost and started it with 'new AppHost().Init();' in your Global.asax Application_Start()]
   ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory..cctor() in C:\src\ServiceStack\src\ServiceStack\WebHost.EndPoints\ServiceStackHttpHandlerFactory.cs:45

[TypeInitializationException: Der Typeninitialisierer für "ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory" hat eine Ausnahme verursacht.]

[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
   System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
   System.Web.Configuration.HttpHandlerAction.Create() +57
   System.Web.Configuration.HandlerFactoryCache..ctor(HttpHandlerAction mapping) +19
   System.Web.HttpApplication.GetFactory(HttpHandlerAction mapping) +96
   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +125
   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

My global class is:

public class Global : System.Web.HttpApplication
    {
        /// Web Service Singleton AppHost
        public class InfoAppHost : AppHostBase
        {
            //Tell Service Stack the name of your application and where to find your web services
            public InfoAppHost()
                : base("Services", typeof(InfoService).Assembly) { }

            public override void Configure(Funq.Container container) { }
        }

        protected void Application_Start(object sender, EventArgs e)
        {
            //Initialize your application
            var appHost = new InfoAppHost();
            appHost.Init();
        }
    }

But it seems to never get called. Compiling the example project from the homepage works fine - but I would like to follow the example from the homepage. Any ideas how to solve this problem ?

4

5 回答 5

2

我已经删除了我的测试项目并再次尝试了该教程。

创建 Global.asax 文件时,我删除了整个类并在该文件中创建了另一个类 Global。似乎 Application_Start 在此类中从未被调用过。

于 2011-09-22T10:20:24.490 回答
1

您可能已经猜到的问题是 appHost.Init() 没有运行。尝试将其包装在 try/catch 中并记录任何可能引发的错误。

于 2011-09-24T05:53:07.043 回答
1

We had the same problem and solved it by setting "Activate 32-bit-applications" to true in the extended ApplicationPool Settings. (sorry, only have a german Windows so the Settings names are rough guesses)

于 2013-12-18T12:19:03.597 回答
0

我花了一段时间才弄清楚我做错了什么导致这个问题......

这发生在我身上,因为我不小心将 Global.asax 文件拖到了我项目的子文件夹中。

于 2013-04-04T17:49:28.480 回答
0

我发现这个错误是由 WebApiConfig 引起的。该示例使用 ServiceStack,不需要 ASP.NET Web API。该行需要在 Gloabal.asax.cs 文件中注释掉。

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        // ** comment out ** WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

        new ProteinTrackerAppHost().Init();
    }
于 2013-10-04T03:11:23.323 回答