Tuesday, 12 March 2024

How to fix Error: "Common Language Runtime detected an invalid program" in D365FO

Recently, we upgraded our environment, which resulted in one of our customizations, previously working flawlessly, throwing the "Common Language Runtime detected an invalid program" error. During the debugging process, we identified a piece of code, to be the root cause of the error.

Error Screenshot:










Code Snippet Causing The Error:



Error Fix: To resolve this issue, I stored the result of DateTime::Now in a variable and then accessed the Ticks property from that variable. This approach eliminated the error, and the code now functions properly as it did before.





Note:
I understand the fix may seem unusual and nonsensical to some, but regardless, it worked. 😊

No comments:

Post a Comment

How to Get Customer Free Text Invoice "Totals" form field value with X++ in D365FO

Customer free text invoices are an essential aspect of financial management in D365FO. In this blog, I have compiled all the code needed to ...