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. 😊