gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 01:25:10 26 4
gpt4 key购买 nike

我正在关注来自 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com