title: VB: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)
body: <p>I am working on an app which needs to import data from Excel.</p>
  
  <p>My solution is using <code>Microsoft.office.Interop.Excel.</code></p>
  
  <p>But I get this error when I debug:</p>
  
  <blockquote>
    <p>Message=Unable to cast COM object of type
    'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
    'Microsoft.Office.Interop.Excel._Application'. This operation failed
    because the QueryInterface call on the COM component for the interface
    with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the
    following error: Error loading type library/DLL. (Exception from
    HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))</p>
  </blockquote>
  
  <p>Below is my code:</p>
  
  <pre><code>Imports Excel = Microsoft.office.Interop.Excel
  
  Private Sub BExcel1_Click(sender As Object, e As EventArgs) Handles BExcel1.Click
      OpenFileDialog1.Filter = "Excel Files|*.xlsx; *.xls; *.xlsm"
      If (OpenFileDialog1.ShowDialog() = DialogResult.OK) Then
          ExcelPath1.Text = OpenFileDialog1.FileName
      End If
  
      Dim XlApp As New Excel.Application
      Dim XlWorkBook As Excel.Workbook
      Dim XlWorkSheet As Excel.Worksheet
      XlWorkBook = XlApp.Workbooks.Open(ExcelPath1.Text)
  
   End Sub
  </code></pre>
  
  <p>I have googled to find some solutions (as following), but they didn't work out:</p>
  
  <ol>
  <li>I have repaired Office</li>
  <li>I have repaired Visual Studio</li>
  <li>I have used the registry editor to check the <code>Computer\HKEY_CLASSES_ROOT\TypeLib\</code>, but under the <code>00020813-0000-0000-C000-000000000046</code>, I got only one version 1.9, it seems not like the conflict between two version?</li>
  </ol>
  
  <p>Any ideas to fix this problem?</p>
  
  <pre><code>VS version:2017 community
  
  Excel version:2016
  
  Microsoft.Office.Interop.Excel version:15.0.0.0
  </code></pre>