title: Why this code throws System.ExecutionEngineException
body: <p><strong>Background:</strong> 
  I am using DirectX 9.0 Managed Libraries to transform arrays of 3d points to 2d screen coordinates.  For speed I use the UnsafeNativeMethods to do all the transformations. </p>
  
  <p><strong>The Problem:</strong>
  If my custom line clipping function is used my application dies without throwing any exceptions, it took me a while to figure out that it was throwing an <em>uncatchable</em> <code>System.ExecutionEngineException</code>.  I have narrowed it down to happening because of the last two lines of my clipping function.</p>
  
  <pre><code>List&lt;Vector3&gt; verticesAfterClipping = new List&lt;Vector3&gt;;
  public unsafe void ClipLine(Line lineToClip)
  {
      this.verticesAfterClipping.Clear();
  
      // Clipping algorithm happens here... (this is psuedo-code of what it does)
      foreach(Vertex in lineToClip.Vertices)
      {
          bool thisIsClipped =   // Set to whether this vertex is clipped
          bool lastWasClipped =  // Set to whether last vertex was clipped
  
          if(thisIsClipped == false &amp;&amp; lastWasClipped == true)
          {
              verticesAfterClipping.Add( /* intersection on clipping plane */ );
              verticesAfterClipping.Add( /* thisVertex */ );
          }
          else if (thisIsClipped == false &amp;&amp; lastWasClipped == false)
          {
              verticesAfterClipping.Add( /* thisVertex */ );
          }
          else if (thisIsClipped == true &amp;&amp; lastWasClipped == false)
          {
              verticesAfterClipping.Add(/* intersection on clipping plane */);
          }
      }
  
      // THIS IS WHERE BAD THINGS HAPPEN
      lineToClip.Vertices = new Vertex[verticesAfterClipping.Count];
      verticesAfterClipping.CopyTo(lineToClip.Vertices, 0);
  }
  </code></pre>
  
  <p>When the <code>verticesAfterClipping</code> list is copied to the <code>lineToClip</code> vertices the <code>lineToClip</code> object is then passed to an UnsafeNativeMethod which transforms these vertices to 2d vertices.  From everything I can see when I step through it in Debug mode it is working completely fine, until it just dies.</p>
  
  <p>I simply cannot figure out what is wrong.  Any help would be much appreciated.</p>