Announcements
Hi friends, my name is Antony.
I've tried to debug this line of code by putting a breakpoint on the class that runs on Post Button and also attaching the process to w3wp.exe.
Then the error appears in output window, but I don't know how to find out which method/class/line is causing the error.
Is this method of debugging is correct? How do I find the line/method that is causing the error?
Any suggestions will be very helpful. Thank you.
Hi Martin. Thanks for your advice.
I accidentally found the error when I checked the ProdRouteJob extension class. In the event handler method I incorrectly declared a variable that should be ProdRouteJob instead ProdJournalBOM which caused the error.
But I'll try and learn your suggested approach to dealing with this kind of error.
Regards,
Antony
Hi Nikolaos. Thank you for your advice.
I've tried putting a breakpoint in Classes\Info\add but the call stack doesn't show up when this error occurs.
Regards,
Antony
I don't think that Info.add() is called for managed exceptions like this. At least it didn't work for me the last time when I tried it.
In addition to Martin's suggestion, a general good approach is to put a breakpoint in Classes\Info\add, this way you can always find out the call stack of any process that prints in the infolog. Including your current exception.
A fast way of finding the place may be configuring Visual Studio to break on InvalidCastException.
Go to Debug > Windows > Exception Settings, search for InvalidCastException and tick System.InvalidCastException in the list of Common Language Runtime Exceptions. Then attach the debugger and try the process again. The debugger should stop at the place where the exception is thrown.
Hi Michael,
What is the version of your Dynamics 365 application? Do you have customizations? If so verify if this could be causing it.
If you don't have customizations, you can search on LCS issue search for known issues. I couldn't find this specific error, but some other which were identical on other application areas. It might be a bug if you don't have customizations yourself. In that case, contact Microsoft Support.
moved to the d365 forum
André Arnaud de Cal...
294,261
Super User 2025 Season 1
Martin Dráb
232,996
Most Valuable Professional
nmaenpaa
101,158
Moderator