如何在Acumatica中调试InvalidCastException异常问题?
Acumatica开发异常调试问题:无法捕获InvalidCastException定位根源
问题概述
系统弹出错误框抛出InvalidCastException异常,常出现在MoveNext命令或其他事件中,但VS2022附加到IIS应用程序时,调试器无法捕获该异常,无法定位问题。
具体场景
1. 扩展代码
public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint> { internal CurrentCostingInfo currentCostingInfo = null; public static bool IsActive() { return true; } protected virtual void _(Events.RowSelecting<CROpportunity> e, PXRowSelecting InvokeBaseHandler) { if (e.Row == null) return; var row = e.Row as CROpportunity; if (UseMarkupInsteadOfMargin == null || !UseMarkupInsteadOfMargin.HasValue) UseMarkupInsteadOfMargin = false; SetDisplayFor_MarkUpOrMargin("CROpportunity", UseMarkupInsteadOfMargin, e.Cache); using (new PXConnectionScope()) { SetOpportunityMarginTotals(row); } int h = 0; } protected virtual void _(Events.FieldSelecting<CROpportunity, CROpportunity.status> e) { if (e.Row == null) return; } protected virtual void _(Events.FieldDefaulting<CROpportunity, CROpportunity.status> e) { if (e.Row == null) return; } protected virtual void _(Events.RowSelected<CROpportunity> e, PXRowSelected InvokeBaseHandler) { int i = 0; InvokeBaseHandler?.Invoke(e.Cache, e.Args); int f = 0; } }
2. 运行时流程
- 触发
IsActive()方法; - 5次触发
Events.FieldSelecting<CROpportunity, CROpportunity.status>; - 触发
Events.RowSelecting方法; - 离开
RowSelecting后,无更多断点触发,但Acumatica弹出InvalidCastException错误框,RowSelected()和FieldDefaulting均未触发。
异常信息
错误提示
System.InvalidCastException2023-06-05 17:58:45 UTC Specified cast is
not valid.PX.Data.PXException2023-06-05 17:58:45 UTC Error: An error occurred
during processing of the field Account ID:Specified cast is not valid.. PX.Data.PXException2023-06-05 17:58:45
UTC Error: An error occurred during processing of the field Account
ID:Specified cast is not valid.. PX.Data.PXException2023-06-05 17:58:45
UTC Error: An error occurred during processing of the field Account
ID:
完整堆栈追踪(InvalidCastException)
at PX.Data.PXFirstChanceExceptionLogger.ProfilerFirstChanceException(Object o, FirstChanceExceptionEventArgs args) at System.Data.SqlClient.SqlBuffer.get_Int32() at PX.Data.PXDataRecord.GetInt32(Int32 i) at PX.Data.PXDBIdentityAttribute.RowSelecting(PXCache sender, PXRowSelectingEventArgs e) at PX.Data.PXCache.OnRowSelecting(Object item, PXDataRecord record, Int32& position, Boolean isReadOnly) at PX.Data.PXCache`1.CreateItem(PXDataRecord record, Int32& position, Boolean isReadOnly) at PX.Data.PXView.CreateResult(PXCache[] caches, PXDataRecord rec, Boolean hascount, Boolean& overrideSort, Boolean& extFilter) at PX.Data.PXView.GetResult(Object[] parameters, PXFilterRow[] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumn[] sorts, Boolean& overrideSort, Boolean& extFilter) at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows) at PX.Data.Automation.Services.NavigationService.FindExistingRow(PXView view, Object current, Object[] searches, String[] sortColumns) at PX.Data.Automation.Services.NavigationService.GetExistingRow(PXView view, IReadOnlyDictionary`2 parameters) at PX.Data.Automation.Services.NavigationService.NavigateToScreen(INavigationScreenInfo screen, IReadOnlyDictionary`2 evaluatedParameters, WindowMode windowMode, String navigationMessage) at PX.Data.PXGenericInqGrph.NavigateTo(String urlOrScreenID, WindowMode windowMode, Nullable`1 lineNbr) at PX.Data.PXGenericInqGrph.<>c__DisplayClass88_3.<GenerateResultField>b__9(PXAdapter adapter) at PX.Data.PXAction`1.RunHandler(PXAdapter adapter) at PX.Data.PXAction`1.<Press>d__38.MoveNext() at PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName, String[] sortcolumns, Boolean[] descendings, Object[] searches, Object[] parameters, PXFilterRow[] filters, DataSourceSelectArguments arguments, Boolean& closeWindowRequired, Int32& adapterStartRow, Int32& adapterTotalRows) at PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments) at PX.Web.UI.PXDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments) at PX.Web.UI.PXDataSourceView.Select(DataSourceSelectArguments arguments, PXDSSelectArguments swarguments, DataSourceViewSelectCallback callback) at PX.Web.UI.PXFormDataProvider.DataBind() at PX.Web.UI.PXCallbackManager.CollectDataControls(Dictionary`2 controlsDic, List`1 controlsList) at PX.Web.UI.PXCallbackManager.RenderClientData(PXCallbackResultMethod resultMethod, XmlWriter writer) at PX.Web.UI.PXCallbackManager.GetCallbackResultInternal(PXCallbackResultMethod resultMethod) at PX.Web.UI.PXCallbackManager.GetCallbackResult(PXCallbackResultMethod resultMethod) at System.Web.UI.Page.RenderCallback() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at PX.Web.UI.PXPage.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error) at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) PX.Data.PXException2023-06-06 13:43:29 UTC
PX.Data.PXException堆栈追踪
at PX.Data.PXFirstChanceExceptionLogger.ProfilerFirstChanceException(Object o, FirstChanceExceptionEventArgs args) at PX.Data.PXCache.OnRowSelecting(Object item, PXDataRecord record, Int32& position, Boolean isReadOnly) at PX.Data.PXCache`1.CreateItem(PXDataRecord record, Int32& position, Boolean isReadOnly) at PX.Data.PXView.CreateResult(PXCache[] caches, PXDataRecord rec, Boolean hascount, Boolean& overrideSort, Boolean& extFilter) at PX.Data.PXView.GetResult(Object[] parameters, PXFilterRow[] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumn[] sorts, Boolean& overrideSort, Boolean& extFilter) at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows) at PX.Data.Automation.Services.NavigationService.FindExistingRow(PXView view, Object current, Object[] searches, String[] sortColumns) at PX.Data.Automation.Services.NavigationService.GetExistingRow(PXView view, IReadOnlyDictionary`2 parameters) at PX.Data.Automation.Services.NavigationService.NavigateToScreen(INavigationScreenInfo screen, IReadOnlyDictionary`2 evaluatedParameters, WindowMode windowMode, String navigationMessage) at PX.Data.PXGenericInqGrph.NavigateTo(String urlOrScreenID, WindowMode windowMode, Nullable`1 lineNbr) at PX.Data.PXGenericInqGrph.<>c__DisplayClass88_3.<GenerateResultField>b__9(PXAdapter adapter) at PX.Data.PXAction`1.RunHandler(PXAdapter adapter) at PX.Data.PXAction`1.<Press>d__38.MoveNext() at PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName, String[] sortcolumns, Boolean[] descendings, Object[] searches, Object[] parameters, PXFilterRow[] filters, DataSourceSelectArguments arguments, Boolean& closeWindowRequired, Int32& adapterStartRow, Int32& adapterTotalRows) at PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments) at PX.Web.UI.PXDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments) at PX.Web.UI.PXDataSourceView.Select(DataSourceSelectArguments arguments, PXDSSelectArguments swarguments, DataSourceViewSelectCallback callback) at PX.Web.UI.PXFormDataProvider.DataBind() at PX.Web.UI.PXCallbackManager.CollectDataControls(Dictionary`2 controlsDic, List`1 controlsList) at PX.Web.UI.PXCallbackManager.RenderClientData(PXCallbackResultMethod resultMethod, XmlWriter writer) at PX.Web.UI.PXCallbackManager.GetCallbackResultInternal(PXCallbackResultMethod resultMethod) at PX.Web.UI.PXCallbackManager.GetCallbackResult(PXCallbackResultMethod resultMethod) at System.Web.UI.Page.RenderCallback() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at PX.Web.UI.PXPage.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error) at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
疑问
数据库表中未找到AccountID字段,如何让系统在调试器中抛出异常,以便定位问题根源?
内容的提问来源于stack exchange,提问作者MarkJoel60
相关产品推荐
相关产品推荐

