title: How to correct Stack UNDERflow error
body: <p>I get an InvalidProgramException when trying to execute a particular procedure in an application I am working on when it has been compiled with optimizations (Visual Studio 2015).  I used PEVerify to see what it says about the problem, and it tells me "Method[offset 0x00000351] Stack underflow".</p>
  
  <p>Obviously I can fix the problem by turning optimizations off, but that is a less than optimal solution, as is waiting for MS to fix whatever bug causes it in the next version.</p>
  
  <p>What can I do to fix a stack underflow error?  If I had to guess I'd say that it's probably related to the fact that this class is somewhere around 18k lines, but there's not a lot I can do about that...</p>
  
  <p><strong>Edit</strong>: Just to be clear, I don't expect an answer along the lines of "delete lines 6276 and 6277", what I am looking for is general strategies for troubleshooting this type of problem in .net.  Something like the answers to this ActionScript question: <a href="https://stackoverflow.com/questions/6270837/how-to-debug-a-runtime-stack-underflow-error">How to debug a runtime stack underflow error?</a>, except specific to .net.  I am posting this so that the next person that has this type of problem will have a starting point for what they might try to work around this issue.</p>