3

我在独立模式下使用 ServiceStack。它现在正在TypeInitialzationException执行时给出Apphost.Start()

当时,我正在实现一些自定义过滤器,但是从唯一过滤的 DTO 类中删除注释并没有解决问题。

堆栈跟踪没有显示我所涉及的任何类,而失败的类是JsvReader我没有明确使用的。

怎样才能防止这个问题?

注意:我刚刚使用 nuget 更新了所有包,所以这是目前的最新版本,所有 ServiceStack 组件都是 3.9.43。

异常详情

System.TypeInitializationException occurred
  HResult=-2146233036
  Message=The type initializer for 'ServiceStack.Text.Jsv.JsvReader`1' threw an exception.
  Source=ServiceStack.Text
  TypeName=ServiceStack.Text.Jsv.JsvReader`1
  StackTrace:
       at ServiceStack.Text.Jsv.JsvReader`1.GetParseFn()
       at ServiceStack.Text.Jsv.JsvReader.GetParseFn(Type type)
       at ServiceStack.ServiceModel.Serialization.StringMapTypeDeserializer..ctor(Type type)
       at ServiceStack.ServiceHost.RestPath..ctor(Type requestType, String path, String verbs, String summary, String notes)
       at ServiceStack.ServiceHost.ServiceController.RegisterRestPaths(Type requestType)
       at ServiceStack.ServiceHost.ServiceController.RegisterCommon(Type serviceType, Type requestType, Type responseType)
       at ServiceStack.ServiceHost.ServiceController.RegisterNService(ITypeFactory serviceFactoryFn, Type serviceType)
       at ServiceStack.ServiceHost.ServiceController.Register(ITypeFactory serviceFactoryFn)
       at ServiceStack.ServiceHost.ServiceManager.Init()
       at ServiceStack.WebHost.Endpoints.Support.HttpListenerBase.Init()
       at ArdWebServer.Program.Main(String[] args)
  InnerException: System.TypeInitializationException
       HResult=-2146233036
       Message=The type initializer for 'ServiceStack.Text.Common.DeserializeSpecializedCollections`2' threw an exception.
       Source=ServiceStack.Text
       TypeName=ServiceStack.Text.Common.DeserializeSpecializedCollections`2
       StackTrace:
            at ServiceStack.Text.Common.DeserializeSpecializedCollections`2.get_Parse()
            at ServiceStack.Text.Common.JsReader`1.GetCoreParseFn[T]()
            at ServiceStack.Text.Common.JsReader`1.GetParseFn[T]()
            at ServiceStack.Text.Jsv.JsvReader`1..cctor()
       InnerException: System.NullReferenceException
            HResult=-2147467261
            Message=Object reference not set to an instance of an object.
            Source=ServiceStack.Text
            StackTrace:
                 at ServiceStack.Text.PlatformExtensions.GenericTypeArguments(Type type)
                 at ServiceStack.Text.Common.DeserializeSpecializedCollections`2.GetGenericEnumerableParseFn()
                 at ServiceStack.Text.Common.DeserializeSpecializedCollections`2.GetParseFn()
                 at ServiceStack.Text.Common.DeserializeSpecializedCollections`2..cctor()
            InnerException: 

我的应用主机

    public class AppHost : AppHostHttpListenerBase
    {
        public AppHost() : base("IAM Tools Service Stack Host", typeof (Tims.Global).Assembly)
        {                
            CatchAllHandlers.Add(
                (httpMethod, pathInfo, filePath) => 
                    Tims.Support.StaticFileHandler.Factory(
                        Params.Instance.HttpDataDir, 
                        "/", 
                        pathInfo
                )
            );
        }

        public override void Configure(Funq.Container container)
        {                
            SetConfig(new EndpointHostConfig()
                      {

                          DebugMode = true,

                          WriteErrorsToResponse = true
                      });        
        }
    }
4

0 回答 0