title: How to fix the exception, when I call new Microsoft.Office.Interop.Word.Application()
body: <p>When I call new Microsoft.Office.Interop.Word.Application() to initialize, an error occurred. The message is as follows:</p>
  
  <blockquote>
    <p>Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).</p>
  </blockquote>
  
  <p>Some help was obtained after searching in MSDN(<a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/d34c4f78-46f3-478e-9c44-95ea8461e46f/unable-to-cast-com-object-of-office-interop-word?forum=vsto" rel="nofollow noreferrer">this page</a>).
  But when I checked <strong>HKEY_CLASSES_ROOT\Wow6432Node\Interface{00020970-0000-0000-C000-000000000046}\TypeLib</strong>, I found my "Version" is 3.0 instead of 8.6, "(Default)" is {00020905-0000-4B30-A977-D214852036FF} instead of {00020905-0000-0000-C000-000000000046}. And in <strong>HKEY_CLASSES_ROOT\Wow6432Node\TypeLib{00020905-0000-0000-C000-000000000046}</strong>, there should only be <strong>1 subkey</strong> named 8.7 instead of 8.6.</p>
  
  <p>I have tried to change the Version in <strong>HKEY_CLASSES_ROOT\Wow6432Node\Interface{00020970-0000-0000-c000-000000000046}\TypeLib</strong> to 8.7 and (Default) to {00020905-0000-0000-0000-c000-000000000046}, but it still doesn't work.
  I also, according to <a href="https://support.office.com/en-us/article/repair-an-office-application-7821d4b6-7c1d-4205-aa0e-a6b40c5bb88b?omkt=en-US&amp;ui=en-US&amp;rs=en-US&amp;ad=US" rel="nofollow noreferrer">this page</a> instructions try to "Quick Repair" and completely reinstall Office. How do I modify the registry keys to be successful? </p>
  
  <p>My Word version is Professional 2019(Click-to-run).</p>
  
  <p>In addition, <strong>I'm sure my code is correct</strong>. Because I wrote the code on another computer where it executed perfectly.</p>
  
  <p>Here's a little bit of my code:</p>
  
  <pre><code>    Microsoft.Office.Interop.Word.Application wordApp;
      Microsoft.Office.Interop.Word.Document wordDoc;
      wordApp = new Microsoft.Office.Interop.Word.Application();
      wordApp.Visible = visible;
      Object Nothing = Missing.Value;
      wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
  </code></pre>