Creating a .NET based DLL for VBA

As an experiment, I want to create a c#/.Net DLL that I can reference from MS Access VBA.  So far, I have used two examples - but each one gives me the following error when I try to add it as a refernce:

"Can't add a reference to the specified file".

Here is one of the examples that I used: http://www.geeksengine.com/article/create-dll.html

Adding the reference would be ideal, but I could also use late binding.  However, I just need to find a starting point and figure out what I'm doing wrong.

Any help would be greatly appreciated.
Andy BrownDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Are you sure you followed the example to the letter...it has being quite some years since a tested this and it worked just fine...i have made the .dll and used it just fine on my Access application.
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
Did you use .NET 4?
0
ste5anSenior DeveloperCommented:
1. Did you compile it for the correct target CPU? x86 or x64 depending on your Office (VBA host) platform.
2. Did you register it correctly? regasm path\to\library.dll  /codebase /tlb.
3. Did you reference it?

The /tlb switch in step 2 is crucial, cause you need to register the created .tlb file. Also using the VS registration requires that you run VS with admin privileges (not recommended) and VS may lock sometimes the output file, thus an old version is registered instead. I had these in the past, thus manually registering it in a separate command shell window with the necessary privileges.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andy BrownDeveloperAuthor Commented:
Thank you, everyone, for coming back to me - I'll take a closer look.
0
Andy BrownDeveloperAuthor Commented:
Thank you guys (esp Ste5an).  As soon as I added:

  /codebase /tlb.

To the end - it all worked.

Thank you again everyone - that's been a big help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.