title: MS Word Automation in C# - Unable to cast object of type 'System.String[*]' to type 'System.String[]'
body: <p>I use this code to get a String array of headings used in a MS Word 2007 document (.docx):</p>
  
  <pre><code>dynamic arr = Document.GetCrossReferenceItems(WdReferenceType.wdRefTypeHeading);
  </code></pre>
  
  <p>Using the debugger, I see that <code>arr</code> is dynamically assigned a String array with titles of all my headings in the document (about 40 entries). So far so good.</p>
  
  <p>Then, I want to access the strings, but no matter how I do it, I get the following exception:</p>
  
  <pre><code>InvalidCastException: 
             Unable to cast object of type 'System.String[*]' to type 'System.String[]'.
  </code></pre>
  
  <p>I have tried different ways of accessing the strings:</p>
  
  <p>By index:</p>
  
  <pre><code>String arr_elem = arr[1];
  </code></pre>
  
  <p>By casting to an IEnumerable:</p>
  
  <pre><code>IEnumerable list = (IEnumerable)arr;
  </code></pre>
  
  <p>By using a simple foreach loop:</p>
  
  <pre><code>foreach (String str in arr)
  {
     Console.WriteLine(str);
  }
  </code></pre>
  
  <p>However, no matter what I try, I always end up with the same exception as shown above.</p>
  
  <p>Can anyone explain what I am missing here / what I am doing wrong? And especially <code>String[*]</code> - what does it mean?</p>