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 ?

3
  • Could it be that you're mixing PMSInfoAppHost and InfoAppHost or am I missing something?
    – Filburt
    Sep 22, 2011 at 8:49
  • No, this was just done to protect the innocent (customer) :) And i forgot to change this occurence in the example. Sep 22, 2011 at 9:00
  • So the exception is not a result of PMS ;-)
    – Filburt
    Sep 22, 2011 at 9:17

5 Answers 5

2

I've deleted my test project and tried the tutorial once again.

When creating the Global.asax file I've deleted the whole class and made another class Global in this file. It seems Application_Start never got called in this class.

1

The problem as you might have guessed is that appHost.Init() hasn't run. Try wrapping it in a try/catch and logging any errors that might have been thrown.

1
  • I've tried this - but it didn't really work - there was never an exception thrown. It just didn't call my appHost.Init(). After starting over with a new Global.asax file it worked. Sep 26, 2011 at 7:17
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)

0

Took me a while to figure out what I was doing wrong to cause this issue...

this happened to me because I accidentally dragged the Global.asax file into a subfolder in my project.

0

I found that this error is caused by the WebApiConfig. The example is using ServiceStack and does not not need ASP.NET Web API. That line needs to be commented out inthe Gloabal.asax.cs file.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.