我试图在IIS 8.5上将简单测试ServiceStack(版本4.0.30)应用程序部署到Windows Server 2012。 .NET的版本是4.5。应用程序池设置为.NET 4.0,集成模式。在IIS中,我创建了一个新网站并将其映射到物理文件夹。该文件夹包含web.config,然后所有的dll都在bin文件夹下。ServiceStack部署IIS 8.5 - 获取“ServiceStack.HttpHandlerFactory”的类型初始值设定项引发异常
我可以从Visual Studio 2013成功运行项目,但在部署后,我在下面看到这些错误消息。我寻找其他类似的错误,但似乎没有看到任何相同的东西。
这里是异常堆栈跟踪:
[NullReferenceException: Object reference not set to an instance of an object.]
ServiceStack.HttpHandlerFactory..cctor() +363
[TypeInitializationException: The type initializer for 'ServiceStack.HttpHandlerFactory' threw an exception.]
ServiceStack.HttpHandlerFactory..ctor() +0
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +256
System.Activator.CreateInstance(Type type, Boolean nonPublic) +127
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +14407909
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +198
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +83
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +57
System.Web.HttpApplication.GetFactory(String type) +94
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +375
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
配置文件看起来是这样的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- ServiceStack: CustomPath /api -->
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<!-- ServiceStack: Required for IIS7 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
<!-- ServiceStack: Required for MONO -->
<system.web>
<httpHandlers>
<add path="api*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<urlCompression doStaticCompression="false" />
</system.webServer>
<runtime>
</runtime>
</configuration>
谢谢!
您是否正在[初始化您的Global.asax.cs中的AppHost](https://github.com/ServiceStackApps/Todos/blob/master/src/Todos/Global.asax.cs#L83) ? – mythz 2014-08-28 20:37:34
好吧,我是个白痴,Global.asax.cs文件没有部署到文件夹,同时我正在查看所有这些IIS属性以尝试修复。顺便说一句,ServiceStack真棒,只是进入它,并留下深刻的印象。谢谢! – kkatsma 2014-08-28 22:15:27