Tracing nonsense location of BPM errors in Custom (C#) code

I have converted a BPM (method directive) from E9 to E10 and am trying to see if it works. The syntax check says everything is okay, and “validate” doesn’t find any errors. However, when the code actually runs, I am getting an error I don’t understand (“Specified cast is not valid.” when I don’t see any casts in the code) and my attempts to identify where the error is occurring are being thwarted by nonsense locations given in the error:

Framework Source:  A001_CustomCodeAction at offset 1629 in file:line:column <filename unknown>:0:100:

Server Trace Stack:     at lambda_method(Closure , Object , Object )
   at Epicor.Customization.Bpm.BOAD798F6F3C8E4577ABA040CCD1353713.DuplicatePartPostProcessingDirective_ResetValueforDupPart_ED02BDC1BF7445AEE3119D48E649ABEE.A001_CustomCodeAction()
   at Epicor.Customization.Bpm.BOAD798F6F3C8E4577ABA040CCD1353713.DuplicatePartPostProcessingDirective_ResetValueforDupPart_ED02BDC1BF7445AEE3119D48E649ABEE.ExecuteCore()
   at Epicor.Customization.Bpm.DirectiveBase`3.Execute(TParam parameters) in C:\_Releases\ICE\ICE3.2.200.15\Source\Server\Internal\Lib\Epicor.Customization.BPM\DirectiveBase.Generic.cs:line 147

I can find the A001_CustomCodeAction() function on the server under E:\Websites\Epicor10Test\Server\BPM\Sources\BO\Part.DuplicatePart\35\DuplicatePart.Post.ResetValueForDup.cs, which has 245 lines. However, the above error doesn’t tell me what line to look at for this error. The “C:\_Releases” folder refered at the top level of the stack track doesn’t even exist, neither on the client nor the server machine!

I also tried putting a PublishInfoMessage call in a few places in the code, including as the first line in the custom code. But this code apparently doesn’t even get called; my message is never displayed and the error is thrown instead. Why is this? This seems to be a run-time error, not a compile-time error, how can my code never be run if the error is after my debug message? If I comment all the code out after the message then the debug message is printed and no exception is thrown.

How can I identify exactly where this error is occurring without needing to waste a lot of time trying to comment out sections of code?

1 Like

I’m thinking it is a LINQ lamda failing. Much as you’d hate to, a code snip would be helpful.

1 Like

InfoMessages won’t work of there is an error. It would help us help you if you shared your code.

Could this be a reference to an external BPM code? Are there any conditions blocks that call an external BPM?

It would be more useful to see the whole BPM code/flow?