J
jonmaxey
Guest
A recent issue has come up with older VB.NET code which makes use of On Error Resume Next statements. The code is targeted for .NET Framework 4.5.1 and built using Visual Studio 2015. The code is built successfully but there is a very perplexing runtime issue.
When the executable is run, there is a runtime error when a method is called which contains any "On Error" statement. (On Error Resume Next, On Error Goto, etc.) The error reported is "Error: Common Language Runtime detected an invalid program"
In the event log we see this:
Framework Version: v4.0.30319Description: The process was terminated due to an unhandled exception
Exception Info: System.InvalidProgramException
Additionally the code in this area has not changed in years but recent builds of the code are experiencing this issue. We know its not best practice to use On Error statements in VB.NET but this is very old code that would be best left as-is.
After extensive internet searching, we have not been able to find a cause for the issue. Through trial and error with our research, we have been able to resolve the issue by building the project with compiler optimizations disabled. Our hunch is that the issue is caused by a Windows and/or .NET framework update but we don't know which one.
This leads to some questions:
Continue reading...
When the executable is run, there is a runtime error when a method is called which contains any "On Error" statement. (On Error Resume Next, On Error Goto, etc.) The error reported is "Error: Common Language Runtime detected an invalid program"
In the event log we see this:
Framework Version: v4.0.30319Description: The process was terminated due to an unhandled exception
Exception Info: System.InvalidProgramException
Additionally the code in this area has not changed in years but recent builds of the code are experiencing this issue. We know its not best practice to use On Error statements in VB.NET but this is very old code that would be best left as-is.
After extensive internet searching, we have not been able to find a cause for the issue. Through trial and error with our research, we have been able to resolve the issue by building the project with compiler optimizations disabled. Our hunch is that the issue is caused by a Windows and/or .NET framework update but we don't know which one.
This leads to some questions:
- Are there known issues with Windows and/or .NET updates running VB.NET code making use of On Error statements?
- We have tested with compiler optimizations disabled and functionality does not appear to be impacted. The only impact we can see from the change is the resulting binaries are a few KB larger than with the optimizations enabled. Other than the size of the binaries, are there other downstream impacts to disabling the compiler optimizations?
Continue reading...