我正在關注來自http://www.servicestack.net/ServiceStack.Hello/的服務堆棧「Hello World」教程。但是當我嘗試啓動asp.net應用程序時,它說「值不能爲空,參數名稱:EndpointHost.Config」。服務堆棧Hello World教程:異常EndpointHost.Config爲空
完整的異常文本是:
[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
我的全局類是:
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();
}
}
但似乎從來沒有被調用。 從主頁編譯示例項目工作正常 - 但我想從主頁上的示例。 任何想法如何解決這個問題?
難道是你混合'PMSInfoAppHost'和'InfoAppHost'或我錯過了什麼嗎? – Filburt
不,這只是爲了保護無辜(客戶):)而我忘了改變這個例子中的這個事件。 – bernhardrusch
所以這個例外不是PMS的結果;-) – Filburt