title: Is PIA embedding broken in .NET 4.0 beta 2?
body: <p>A while ago, I wrote some Word interop examples in Visual Studio beta 1, and set the reference to <code>Microsoft.Office.Interop.Word</code> to be embedded (set the "Embed Interop Types" = true in the reference properties). These worked fine, and I haven't run them for a while... until today.</p>
  
  <p>Of course, now I'm running under beta 2 of both Visual Studio 2010 and .NET 4.0 - and it seems to be somewhat broken.</p>
  
  <p>Here's the code in question (just dummy example code):</p>
  
  <pre><code>using Microsoft.Office.Interop.Word;
  
  class WordImprovement1
  {
      static void Main()
      {
          Application app = new Application { Visible = true };
          app.Documents.Add();
          Document doc = app.ActiveDocument;            
          Paragraph para = doc.Paragraphs.Add();
          para.Range.Text = "Thank goodness for C# 4";
  
          object filename = "demo.doc";
          object format = WdSaveFormat.wdFormatDocument97;
          doc.SaveAs(FileName: ref filename, FileFormat: ref format);
          doc.Close();
          app.Quit();
      }
  }
  </code></pre>
  
  <p>Here's the exception I get <em>most</em> of the time, when "Embed Interop Types" is set to "true" or I link with "/l" on the command line:</p>
  
  <pre><code>System.MissingMethodException: Method not found:
  'Void Microsoft.Office.Interop.Word._Application.set_Visible(Boolean)'.
     at WordImprovement1.Main()
  </code></pre>
  
  <p>Very occasionally, it works - which is even more bizarre.</p>
  
  <p>If I set "Embed Interop Types" to "false" (or use /r on the command line instead of /l) it all works fine.</p>
  
  <p>If I remove the "Visible = true" property setter it works too... but I <em>know</em> that property's there... it's even suggested by IntelliSense!</p>
  
  <p>While I haven't done exhaustive testing on multiple boxes, I <em>can</em> confirm that my netbook (running Windows 7 instead of Vista, but still .NET 4.0 beta 2) sees the same problem.</p>
  
  <p>Any suggestions as to whether it's me that's broken or .NET 4.0 beta 2?</p>