我在生产环境中的MVC应用程序遇到问题。在我看来,这是一个无意义的空指针异常。另外,我无法在本地复制它。
这是堆栈跟踪:
对象引用未设置为对象的实例。在 App.Controllers.ReservationController.Index(String id)在 C:\ App \ Controllers \ ReservationController.cs:1593行位于 lambda_method(Closure,ControllerBase,Object [])在 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase 控制器,Object []参数)位于 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary'2参数)位于 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,ActionDescriptor actionDescriptor,IDictionary'2 参数)
System.Web.Mvc.Async.AsyncControllerActionInvoker。<> c__DisplayClass42.b__41() 在 System.Web.Mvc.Async.AsyncResultWrapper。<> c__DisplayClass8'1.b__7(IAsyncResult _),位于System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult'1.End()
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) System.Web.Mvc.Async.AsyncControllerActionInvoker。<> c__DisplayClass37。<> c__DisplayClass39.b__33() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker。<> c__DisplayClass4f.b__49() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker。<> c__DisplayClass4f.b__49()
这是堆栈跟踪所引用的行(1593)上的代码:
this.CheckInvalidSegmentStatus();
有关某些附加信息:
CheckInvalidSegmentStatus
函数是属于我要从中调用它的控制器的方法; this
是因为我在调用触发错误的函数之前正在验证它:if (this.CurrentPNR != null)
; 更多代码:
protected virtual void CheckInvalidSegmentStatus()
{
//check if booking has invalid status segments
var hasWLSegmentStatus = false;
if (this.CurrentPNR.GDSReservation != null)
{
hasWLSegmentStatus = (
from r in this.CurrentPNR.GDSReservation.AirReservations.NullToEmpty()
from f in r.Fares.NullToEmpty()
from q in f.Quotes.NullToEmpty()
from si in q.SegmentInfo.NullToEmpty()
let seg = si.Segment as Air.Segment
where seg != null && seg.StatusCode != null && seg.StatusCode[1] == 'L'
select seg
).Count() > 0;
}
if (hasWLSegmentStatus)
{
this.CurrentPNR.ErrorList.Add(new Message
{
ErrorMessage = TTS.Framework.Resources.ResourceManager.GetText("Reservation.ReservationHasSegmentsInWaitListStatus"),
ErrorType = ErrorType.Warning
});
}