title: Problems retrieving content controls with Open XML sdk
body: <p>I am developing a solution that will generate word-documents. The word-documents are generated on the basis of a template document which has defined content controls. Everything was working good for me when I had only one content control in my template, but after expanding the template document with more content controls, I am getting exceptions. It seems like I am not finding the content controls. </p>
  
  <p>This is my method:</p>
  
  <pre><code>private void CreateReport(File file)
  
      {
          var byteArray = file.OpenBinary();
          using (var mem = new MemoryStream())
          {
              mem.Write(byteArray, 0, byteArray.Length);
              try
              {
                  using (var wordDoc = WordprocessingDocument.Open(mem, true))
                  {
                      var mainPart = wordDoc.MainDocumentPart;
  
                      var firstName = mainPart.Document.Body.Descendants&lt;SdtBlock&gt;().Where
                          (r =&gt; r.SdtProperties.GetFirstChild&lt;Tag&gt;().Val == "FirstName").Single();
                      var t = firstName.Descendants&lt;Text&gt;().Single();
                      t.Text = _firstName;
  
                       var lastName = mainPart.Document.Body.Descendants&lt;SdtBlock&gt;().Where
                          (r =&gt; r.SdtProperties.GetFirstChild&lt;Tag&gt;().Val == "LastName").Single();
                       var t2= lastName.Descendants&lt;Text&gt;().Single();
                       t2.Text = _lastName;
  
                      mainPart.Document.Save();
                      SaveFileToSp(mem);
                  }
  
              }
              catch (FileFormatException)
              {
              }
          }
      }
  </code></pre>
  
  <p>This is the exception I get:</p>
  
  <blockquote>
    <p>An exception of type 'System.InvalidOperationException' occurred in System.Core.dll but was not handled in user code. Innerexception: Null</p>
  </blockquote>
  
  <p>Any tips for me on how I can write better method for finding controls?</p>