title: Why does simple array and Linq generate VerificationException: Operation could destabilize the runtime
body: <p>A very simple ?: operator in C#, combined with a simple array and LINQ (to Objects) call to Reverse() is apparently enough to cause the exception "System.Security.VerificationException: Operation could destabilize the runtime." when run on an ASP.NET web site running with "High" trust (note that "Full" is the default)</p>
  
  <p>Here is the code, plus the straightforward workaround that I came up with:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e) {
      Repro();
      //Workaround();
  }
  
  private IEnumerable&lt;string&gt; Repro() {
      bool test = true;
      string[] widgets = new string[0];
      return test ? widgets : widgets.Reverse();
  }
  
  private IEnumerable&lt;string&gt; Workaround() {
      bool test = true;
      string[] widgets = new string[0];
      if (test) {
          return widgets;
      } else {
          return widgets.Reverse();
      }
  }
  </code></pre>
  
  <p>To set the trust level to "High", the following must be added to the web.config file:</p>
  
  <pre><code>&lt;trust level="High" originUrl=""/&gt;
  </code></pre>
  
  <p>The workaround is functionality equivalent to the problematic ?: operator that repros the problem.  My guess from reading related posts is this is a C# compiler bug.  Anyone know what's going on here?</p>