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:
Imports System.Runtime.InteropServices
Imports RGiesecke.DllExport
Public Module Test
<DllExport("add")> _
Public Function TestExport(left As Integer, right As Integer) As Integer
Return left + right
End Function
End Module
When buliding ut via Visual Studio and trying to access the DLL from Excel:
Public Declare Function add Lib "C:\\...\\VBLib.dll" (left As Integer, right As Integer) As Integer
it works and provide correct results. However, when I tried assembly the DLL with a script I get the error: Can't find DLL entry point
.
Here is the script I am using:
- First I run VBC compiler:
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
- Then I run ildasm.exe:
"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"
- And lastly I run ILAsm.exe:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\ILAsm.exe" /nologo /out:"C:\...\VBLib.dll" "C:\...\VBLib.il" /DLL /resource="C:\...\VBLib.res" /optimize
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. 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!
Note: the file paths have been shortened ...