c# - 服务栈 Hello World 教程 : exception EndpointHost. Config is null

标签 c# web-services servicestack

我正在关注来自 http://www.servicestack.net/ServiceStack.Hello/ 的服务堆栈“Hello World”教程.但是当我尝试启动 asp.net 应用程序时,它说“值不能为空。参数名称: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();
        }
    }

但它似乎永远不会被调用。 从主页编译示例项目工作正常 - 但我想按照主页中的示例进行操作。 有什么想法可以解决这个问题吗?

最佳答案

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

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

关于c# - 服务栈 Hello World 教程 : exception EndpointHost. Config is null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7511954/

相关文章:

c# - asp.net注销后历史记录不清晰的问题

iphone - REST 与 SOAP 对于大量安全数据的比较

nunit - 在 TeamCity 中通过 Console Runner 使用 NUnit 3 时找不到 ServiceStack 许可证

servicestack - 如何计时请求响应生命周期?

servicestack 请求实现搜索的最佳方法

c# - 我怎样才能防止表格再次打开?

c# - 使用字典而不是列表 - 获取条目

c# - 为什么类成员的名称不能与其嵌套类之一相同?

web-services - 如何在服务器端对使用 JSON restful web 服务构建的 web 应用程序进行负载测试?

java - 您应该将扩展 Application 的类放置在 jax.rs 中的何处