Question .net and vba com exposure of dll

bulsatar

Member
Joined
Mar 4, 2012
Messages
8
Programming Experience
1-3
Hello Everyone,

This is my first venture into vb.net but I have a couple years experience in vba and sql. I am trying to create a dll in vb.net that can be used in vba however I seem to be falling short. I have uploaded the file I am attempting using visual studio 2010 express. I have set the com option to be visible and selected the lowest possible build structure. It is a pretty simple dll with only 3 functions that are publicly available however I can't seem to get vba to recognize it in the references. Is there a step I am missing?

Thanks for all the help, greatly appreciated!!!
 

Attachments

  • DXSwrapper.zip
    10.9 KB · Views: 25
Last edited by a moderator:
G'd evening bulsatar,
For what i could see in your project (the project's property page) in the Compile tab you need to mark the "Register for COM Interop" checkbox. Also i notice that you have a designer... Unless you're building an ocx/ActiveX component you shouldn't add nothing but classes.
Another thing that i'd notice is that your references are for the .NetFramework 2.0. This is important because when you register your assembly the regasam.exe is different from the .NetFramework 4.0
Like i said before, i couldn't see your code. but here you'll find some guidelines to expose you .net assembly in COM.
G'd luck
 
To be able to use a COM assembly compiled in .NET in a VBA or VBScript environment, you HAVE to install the assembly to GAC. That also means the assembly needs to be signed with a strong name. Google gacutil.exe.
 
G'd Morning,
In fact you don't need to install the assembly in the GAC. Actually GAC is just an option and may be is better to avoid any version conflict but is not the only one option.
You can register your assembly in any folder you want, just have to get to that folder from the command line and execute the regAsm.exe with the /codebase switch. Something like this:
VB.NET:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe YourAssembly.dll /[b]codebase[/b] /tlb:YourAssembly.tlb
 
Back
Top