0

I've been using Visual Studio 2010 for years now. I have a fairly complex VB.net project that I routinely make changes to. Recently, whenever I'm making changes in debug mode, it throws a System.InvalidProgramException - Common Language Runtime detected an invalid program error which forces me to stop running the program and then restart it again after I've saved my changes.

  • This issue only happens when I make changes to a Sub or Function which is called by another Sub or Function. For example, if I make a change to a button click event, it's fine, but if I make a change to a function that button calls, it errors.
  • A change as simple as adding blank lines in my code will cause this to happen. No code change at all...just literally hitting return to add blank lines between code lines.
  • I installed Visual Studio 2013 thinking it would solve this. It does not. I still get the same errors.
  • I tried moving my project files to a different HDD, I still get the same errors.
  • I thought maybe I have corrupt memory, so I ran a full checkdisk and defrag but I still get the same errors.
  • I've read where this error may happen with very large procedures or projects with lots of variables (although I thought this was fixed in newer .NET versions) so I've cleaned up my code. The largest Module has 30k lines.

The workaround is to stop the project running, save my changes and then restart it...however, that takes time because my program has to reinitialize everything when it runs, so I'd prefer to be able to make changes while debugging.

Also, I have .NET framework 4.5 installed

Update: I loaded up a backup of my code from a month ago and it runs fine...so apparently some recent changes I've made are causing this error. Once I figure out what's changed, I'll update this just for future reference in case anyone else runs into the same issue.

Chase Rocker
  • 1,908
  • 2
  • 13
  • 14
  • Do you have any references to COM interop assemblies with _Embed Interop Types_ set to true? – Jony Adamit Sep 05 '15 at 16:40
  • 30k lines is huge... – jessehouwing Sep 05 '15 at 17:08
  • Do you have optimization enabled in the build settings? Try turning it off while developing: http://stackoverflow.com/a/24572087/736079 – jessehouwing Sep 05 '15 at 17:10
  • I have had that happen several times in the past few days. Everytime, the edits were to the method executing and the change I made were kind of radical like wrapping the current line inside a If block or adding an Else and/or trying to Set the Current Line to code just added. Sometimes the error is deferred until the next time it is supposed to execute that edited method. In all cases the changes were either substantial or radical, or in code that VS uses oddly (like a TypeConverter) and nothing to do with the size/aspects of the program. I just assume it is am Edit/Run limit. VS2012 – Ňɏssa Pøngjǣrdenlarp Sep 05 '15 at 17:11
  • @JonyAdamit no I don't, all the Embed Interop Types are false – Chase Rocker Sep 05 '15 at 21:30
  • @jessehouwing _enable code optimization_ is OFF in my build settings. – Chase Rocker Sep 05 '15 at 21:42
  • @Plutonix yes I believe I've seen what you're describing. From time to time when making changes while debugging, it apparently gets confused with the code and I've had to restart...but that's different than this. If I make a change in a Sub, the program errors at the line that calls that Sub, it doesn't even make it to my code change. It's as if the compiler is saying, _"Something has changed in that Sub I don't understand, I can't continue"_ – Chase Rocker Sep 05 '15 at 21:47
  • **Update:** I loaded up a backup of my code from a month ago and it runs fine...so apparently some recent changes I've made are causing this error. Once I figure out what's changed, I'll update this just for future reference in case anyone else runs into the same issue. – Chase Rocker Sep 05 '15 at 22:28

0 Answers0