title: ExecutionEngineException only when debugging
body: <p>I have C# code that throws ExecutionEngineException only when I debug it. When I just run it from Visual Studio without debugging (press the "Start without debugging") button, this piece of code works OK. But when I debug it from Visual Studio it throws ExecutionEngineException. </p>
  
  <p>Due to this problem I cannot debug my application, as the code I am trying to debug is executed AFTER the problematic piece of code.</p>
  
  <p>Here are some details:</p>
  
  <ul>
  <li>I am using Visual Studio 2012</li>
  <li>The main application is a C++/CLI application that calls my C# code</li>
  <li>The application runs for some time until it reaches the problematic lines of code in C#</li>
  <li>The relevant code is a query against an Entity Framework context.</li>
  <li>I am using Entity Framework 5</li>
  <li>The DB where my entities are stored is SQL Server LocalDB (the one that comes with VS2012)</li>
  </ul>
  
  <p><strong>Edit</strong></p>
  
  <p>Further investigation shows that the actual problem is an access violation exception that originates in the default constructor of System.Data.DataSet, which also happens if I just write <code>new DataSet()</code>.</p>
  
  <p><strong>Edit 2</strong>
  I created a small application that demonstrates this problem. The source code can be found <a href="https://docs.google.com/file/d/0B4QQDeKuMr4eQ3IwZERmNTctbDQ/edit" rel="nofollow">here</a>. </p>
  
  <p>You are welcome to compile it and try and run the project <code>Application</code>. It should crash in <code>Adder.cs</code> with <code>ExecutionEngineException</code> when creating a new <code>DataSet</code>. Please note that the debugger should be Mixed and not Managed/Native.</p>