Question

How Can I Debug this issue when it won't cause a break in Visual Studio on Error


Userlevel 4
Badge

This comes up from time to time. Acumatica will throw an error (popping up an error box). It is usually on the "MoveNext" command, but it sometimes happens in other events. But when I attach VS2022 to the IIS app, it never throws an error inside of my debugger, so I can't see where the problem is.

This is the latest example of this...

First this is the C# Extension code:

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;
}

When I Run it, this is what happens: 

1) IsActive() gets hit, of course.

2) Then I hit the (Events.FieldSelecting<CROpportunity, CROpportunity.status> e) 5 times. 

3) Then I hit the Events.RowSelecting<CROpportunity> method. 

4) When I leave RowSelecting, I don't hit any more breakpoints, but this error message shows in Acumatica:
 

 

RowSelected() is never hit, and neither is the FieldDefaulting method.

This is the Trace info for Exceptions: 

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:

So the issue is with "AccountID" -- except there is no AccountID field in the database table that I can see.

How do I go about seeing what is really going on? I need it to allow the system to throw an error, but it seems to be suppressing that and handling it in the popup, which tells me next to nothing.


17 replies

Userlevel 1

Here I show how to make a breakpoint with visual.

steps here.

 


When you have run as administrator, you need to do the same step again.
 

let it turn red and you can go to the screen and do something automatically it will go into this event and you can see what's going on.​​​​
 

 

Userlevel 4
Badge

Thanks for the reply Saul. I have all of that. My problem isn’t knowing how to debug anything, it is debugging this particular issue, since the breakpoints work, but the error still happens. Maybe I didn’t make that clear in the description… But I am attaching and running things fine. 

 

It’s just this error seems to be happening outside of my code,

Userlevel 6
Badge +3

Can you share the full trace of the exception?

Userlevel 4
Badge

There are 4 errors. Do you want all of them? I think they are similar,.

This is the top error -- a System.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)

Userlevel 4
Badge

This is the 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) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

Badge +11

Is it possible the error is occurring as a result of a different customization?

I don't think (although I'm not certain) that debugging one project debugs all projects.

Userlevel 4
Badge

@darylbowman : That’s an interesting question. I believe that if an error were occurring in a different customization, the error would still stop the run in VS2022, and I would get a message that it could not navigate to the source code…

However, there is another customization published. It is an Acumatica customization from their GitHub page. (And this is a few revs up from when it was published last.) I can ad the source  code to my project and see if that helps me find anything. It’s worth a try, thanks for the idea.

Userlevel 4
Badge

@darylbowman : Well it was worth a shot, but no luck. I brought in the Acumatica Github projects as source, and compiled them into the same solution, and it made no difference. The error still happens outside of anywhere I can view it. 

Badge +11

Have you tried unpublishing the other packages just to make sure it is actually your package causing the error? If nothing else, you can start commenting out blocks of code. It seems like it’s happening in a RowSelecting event.

Userlevel 4
Badge

I did unpublish everything except this package. It is happening AFTER the RowSelecting logic is run. I get all of the way through that with no error. When I step out of Row Selecting, the error shows up (in the ERP, not in the code.)

The error message shows “Account ID” which is not my field, and nothing in this Extension touches it. AFAIK, that field only exists in the Account database table. which I never touch, so its all very strange. 

Acumatica must have some sort of an internal Try...Catch set up that is catching this error and displaying the message. I am guessing that somehow, something I am doing is causing something in Acumatica to change the AccountID, and the value it is trying to use is invalid. IDK. It’s really frustrating trying to debug it when they have, essentially, disabled my debugger. 

Badge +11

In the original code you posted, you are using the event signature which allows you to extend an existing event, but you never called the base event. Is this intentional?

Userlevel 4
Badge

Yes, I was only creating the event so I could set a breakpoint in it. 

Badge +11

This one?

    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;
}

 

Userlevel 4
Badge

Daryl, 

This one?

 

I’m sorry, but I don’t understand the question? Are you asking me if I set a breakpoint in that function? Yes, I did. On the if (e.row == null line. I set a breakpoint and it was never hit. That’s the main issue. The actual problem isn’t my issue… it is I don’t even know how to go about solving the problem. This has come up before, and I was just wondering what everyone else is doing when it does.

It seems Acumatica has a try catch somewhere that is catching these kinds of errors and handling them in their pop up message -- which is not informative enough to guide me. I am not understanding hoe the (very long) error log helps me, either.

 

Has no one else ever run into this? What do you do to debug it?

 

 

Badge +11

 

protected virtual void _(Events.RowSelecting<CROpportunity> e, PXRowSelecting InvokeBaseHandler)
{
}

A code block like this ☝🏻is designed to override the base version, which is this 👇🏻

protected virtual void _(Events.RowSelecting<CROpportunity> e)
{
}

But unless you are trying to avoid calling whatever is in the base method, in the override, you’d want to call the base method so that executes as well. Otherwise, the base method will never run.

 

If there is a base method for the RowSelecting event in that graph, your code is essentially disregarding it entirely and it will never run. In order to allow the base code to run and also run your code, I would expect something like this:

protected virtual void _(Events.RowSelecting<CROpportunity> e, PXRowSelecting InvokeBaseHandler)
{
if (e.Row == null) return;
var row = e.Row as CROpportunity;

// this runs the base method
InvokeBaseHandler?.Invoke(e.Cache, e.Args);

if (UseMarkupInsteadOfMargin == null || !UseMarkupInsteadOfMargin.HasValue)
UseMarkupInsteadOfMargin = false;

SetDisplayFor_MarkUpOrMargin("CROpportunity", UseMarkupInsteadOfMargin, e.Cache);

using (new PXConnectionScope())
{
SetOpportunityMarginTotals(row);
}
int h = 0;
}

 

This may have nothing to do with the original problem, but then again, it could. Either way, it’s probably important that you understand what’s happening, if you didn’t.

Userlevel 7
Badge

Hi @mjgrice32 were you able to find a solution? Thank you!

Userlevel 4
Badge

@Chris Hackett :

Nope. In my case, since it was on  my development system, and not my customer’s site, I deleted the entire IIS App, and reinstalled it, connecting to the existing database, and the problem went away.

But the issue of not being able to adequately put breakpoints is something I have run into before (and suspect I will again) and every time I do, it send chills up my spine, since there is no way I know of to debug it. And the log files, at least for me, are utterly useless.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved