title: How to build a COM visible DLL from script?
body: <p>I am trying to build a simple VB.NET COM-visible DLL (I want it to be accessible without registering it) from script. The vb file is simple as hell:</p>
  
  <pre><code>Imports System.Runtime.InteropServices
  Imports RGiesecke.DllExport
  
  Public Module Test
      &lt;DllExport("add")&gt; _
      Public Function TestExport(left As Integer, right As Integer) As Integer
          Return left + right
      End Function
  End Module
  </code></pre>
  
  <p><strong>When buliding ut via Visual Studio and trying to access the DLL from Excel:</strong></p>
  
  <pre><code>Public Declare Function add Lib "C:\\...\\VBLib.dll" (left As Integer, right As Integer) As Integer
  </code></pre>
  
  <p><strong>it works and provide correct results. However, when I tried assembly the DLL with a script I get the error: <code>Can't find DLL entry point</code>.</strong></p>
  
  <p>Here is the script I am using:</p>
  
  <ol>
  <li>First I run VBC compiler:</li>
  </ol>
  
  <p><code>vbc.exe /noconfig /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Data,System.Diagnostics,System.Linq,System.Xml.Linq,System.Threading.Tasks /optioncompare:Binary /optionexplicit+ /optionstrict:custom /nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 /optioninfer+ /nostdlib /platform:x86 /rootnamespace:VBLib /sdkpath:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5" /highentropyva+ /reference:"C:\...RGiesecke.DllExport.Metadata.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /out:"C:\...\VBLib.dll" /subsystemversion:6.00 /target:library Class1.vb</code></p>
  
  <ol start="2">
  <li>Then I run <strong>ildasm.exe</strong>:</li>
  </ol>
  
  <p><code>"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\ildasm.exe" /quoteallnames /unicode /nobar /out:"C:\...\VBLib.il" "C:\...\VBLib.dll"</code></p>
  
  <ol start="3">
  <li>And lastly I run <strong>ILAsm.exe</strong>:</li>
  </ol>
  
  <p><code>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\ILAsm.exe" /nologo /out:"C:\...\VBLib.dll" "C:\...\VBLib.il" /DLL /resource="C:\...\VBLib.res"  /optimize</code></p>
  
  <p>I copied the above procedures almost word for word from Visual Studio Build (Detailed view) and they all run w/o errors producing a DLL. However, I still get the error above. <strong>In any case if there is a shorter and working script to provide a COM-visible DLL from a single VB.NET file I would much appreciate!</strong></p>
  
  <p><em>Note: the file paths have been shortened <code>...</code></em></p>