我收到以下消息:
对象引用未设置为对象的实例
当尝试记录服务抛出的异常时,我在ApphostBase中使用以下服务异常处理程序
ServiceExceptionHandlers.Add((httpReq, request, exception) => {
Logger.Error(exception);
return DtoUtils.CreateErrorResponse(request, exception);
});
ServiceStack.dll抛出异常
at ServiceStack.DtoUtils.CreateErrorResponse(Object request, Exception ex)
at MyApp.<>c.<Configure>b__3_16(IRequest httpReq, Object request, Exception exception) in C:\Users\Company\Documents\Visual Studio 2015\Projects\MyApp\src\MyApp\MyApp\AppHost.cs:line 175
at ServiceStack.ServiceStackHost.OnServiceException(IRequest httpReq, Object request, Exception ex)
at ServiceStack.Host.ServiceRunner`1.HandleException(IRequest request, TRequest requestDto, Exception ex)
at ServiceStack.Host.ServiceRunner`1.Execute(IRequest request, Object instance, TRequest requestDto)
at ServiceStack.Host.ServiceRunner`1.Process(IRequest requestContext, Object instance, Object request)
at ServiceStack.Host.ServiceExec`1.Execute(IRequest request, Object instance, Object requestDto, String requestName)
at ServiceStack.Host.ServiceRequestExec`2.Execute(IRequest requestContext, Object instance, Object request)
at ServiceStack.Host.ServiceController.<>c__DisplayClass37_1.<RegisterServiceExecutor>b__1(IRequest reqCtx, Object requestDto)
at ServiceStack.Host.ServiceController.ManagedServiceExec(ServiceExecFn serviceExec, IService service, IRequest request, Object requestDto)
at ServiceStack.Host.ServiceController.<>c__DisplayClass37_0.<RegisterServiceExecutor>b__0(IRequest req, Object dto)
at ServiceStack.Host.ServiceController.Execute(Object requestDto, IRequest req)
at ServiceStack.HostContext.ExecuteService(Object request, IRequest httpReq)
at ServiceStack.Host.RestHandler.GetResponse(IRequest request, Object requestDto)
at ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)
第175行是:
return DtoUtils.CreateErrorResponse(request, exception);
请求和异常都有值。我正在运行一个mvc应用程序,并且还使用了ServiceStack.HttpHandlerFactory处理的api。我正在使用ServiceStack v4.5
答案 0 :(得分:1)
最新的ServiceStack v4.5.4版本提供了NullReferenceException issue resolved in this commit。