title: Cannot find the interop type that matches the embedded type 'Microsoft.Office.Interop.Excel._Workbook'. Are you missing an assembly reference?
body: <p>I'm currently writing a custom DLL to facilitate Java to HostExplorer interface. Apparently Java cant access the Host Explorer API directly or at least that's what I'm being told by the Java side, which is working fine. However I foolishly decided to include some Excel automation methods too and here is where I run into the problem.</p>
  <p>The DLL compiles without any error but when I try to access certain elements of the Excel class I've written I get the following errors:</p>
  <blockquote>
  <ul>
  <li><p>Cannot find the interop type that matches the embedded type 'Microsoft.Office.Interop.Excel._Workbook'. Are you missing an assembly reference?</p>
  </li>
  <li><p>Cannot find the interop type that matches the embedded type 'Microsoft.Office.Interop.Excel._Worksheet'. Are you missing an assembly reference?&quot;</p>
  </li>
  </ul>
  </blockquote>
  <p>This is the relevant code from the XL class:</p>
  <pre><code>Imports System.Windows.Forms
  Imports System.Drawing
  Imports Microsoft.Office.Interop
  
  Public Class XL
      Public XL As Excel.Application
      Public WBS As Excel.Workbooks
      Public WB As Excel._Workbook
      Public WSS As Excel.Worksheets
      Public WS As Excel._Worksheet
  
      Public Sub New(Optional ByVal WBN As String = &quot;&quot;)
          XL = New Excel.Application()
          WBS = XL.Workbooks
  
          If WBN &lt;&gt; &quot;&quot; Then
              WB = WBS.Add(NameOf(WBN))
          Else
              WB = WBS.Add()
          End If
  
          WSS = WB.Worksheets
          WS = WSS(1)
      End Sub
  End Class
  </code></pre>
  <p>This is then referenced and imported into a program I use for testing:</p>
  <pre><code>Imports HE_AUTO
  
  Module Module1
  
      Sub main()
  
          Dim tso As New HE(&quot;TSO&quot;)
          tso.Read(1, 1, 1900)
  
          Dim output As New XL(&quot;test&quot;)
          output.WS.cells(1, 1).value = tso.HostStr
  
          Dim x As String = output.WS.cells(1, 1).value
  
          output.XLSaveAndClose(output.WB.name, &quot;C:\&quot;, &quot;testoutput.xlsx&quot;)
  
          Dim wb1 As Object = output.XLWBOpen(&quot;C:\&quot;, &quot;testoutput.xlsx&quot;)
  
      End Sub
  
  End Module
  </code></pre>
  <p>It is the <strong>output.WS</strong> and <strong>output.WB</strong> that give me the error.
  Now I know that the simple solution is to add a reference to the Office Interop to my test program but as the DLL is to be used as an interface in Java this is not an option.</p>
  <p>Am I missing something obvious?</p>