title: Simple generated MSIL throws "Operation could destabilize the runtime"
body: <p>I've created a very simple function that does the following:</p>
  
  <pre><code>    public static object[] ToArray(int ID) {
          return new object[4];
      }
  </code></pre>
  
  <p>This is the code that generates the MSIL. Why does this throw the "Operation could destabilize the runtime" exception? I can't spot anything wrong with it; it matches the assembly seen in Reflector/Reflexil perfectly.</p>
  
  <pre><code>    // create method
      Type arrayType = typeof(object[]);
      Type intType = typeof(int);
      DynamicMethod dm = new DynamicMethod(methodName, arrayType, new Type[] { intType });
      ILGenerator il = dm.GetILGenerator();
  
      // create the array -- object[]
      il.Emit(OpCodes.Ldc_I4, 4);
      il.Emit(OpCodes.Newarr, typeof(object));
      il.Emit(OpCodes.Stloc_0);
  
      // return the array
      il.Emit(OpCodes.Ldloc_0); 
      il.Emit(OpCodes.Ret);
  
      return dm;
      object result = dm.Invoke(null, new object[] { 1 });
  </code></pre>