title: Outlook 2007 from C# - COM exception, TYPE_E_LIBNOTREGISTERED
body: <p>I'm trying to make a program that would open new Outlook 2007 message.</p>
  
  <p>I've referenced from COM tab Microsoft Outlook 12.0 ObjectLibrary.</p>
  
  <p>These items showed up in references in VS:</p>
  
  <pre><code>Microsoft.Office.Core
  Microsoft.Office.Inerop.Outlook
  </code></pre>
  
  <p>Now I try to invoke following code:</p>
  
  <pre><code>var _outlookInstance = new Microsoft.Office.Interop.Outlook.Application();
  var _message = (OutlookApp.MailItem)_outlookInstance.CreateItem(OutlookApp.OlItemType.olMailItem);
  </code></pre>
  
  <p>where OutlookApp==Microsoft.Office.Interop.Outlook namespace.</p>
  
  <p>While invoking second line of listing I keep getting this exception: (InvalidCastException)</p>
  
  <blockquote>
    <p>Unable to cast COM object of type
    'Microsoft.Office.Interop.Outlook.ApplicationClass'
    to interface type
    'Microsoft.Office.Interop.Outlook._Application'.
    This operation failed because the
    QueryInterface call on the COM
    component for the interface with IID
    '{00063001-0000-0000-C000-000000000046}'
    failed due to the following error:
    Library unregistered.
    (Exception from HRESULT: 0x8002801D
    (TYPE_E_LIBNOTREGISTERED)).</p>
  </blockquote>
  
  <p>That code worked well for Outlook 2003 on my other station.</p>
  
  <p>I'll be grateful for any ideas how to solve it.</p>