我正在尝试将 Servicestack 应用程序部署到 azure 网站。应用程序带有 asp.net 主机和 razor 视图引擎。
现在,它在本地运行良好,没有任何问题。但部署后出现问题。如果我在 web.config 中强制加载程序集,天蓝色将无法加载它。如果不这样做,servicestack 会崩溃 nullpointer 异常。
我检查了应用程序设置,因为天蓝色网站正在运行网页版本 3.xxx
如果需要任何进一步的信息,请告诉我。
这是错误的堆栈跟踪
[NullReferenceException: Object reference not set to an instance of an object.]
ServiceStack.HttpHandlerFactory..cctor() +336
[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) +113
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1136
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +128
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +18
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +46
System.Web.HttpApplication.GetFactory(String type) +86
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +262
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
[更新]我猜问题不在服务堆栈方面。如果我部署它的 C# 版本,一切正常。要在 azure 上编译,需要在 fsproj 文件中添加以下代码。
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets"
Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets"
Condition="true" />