DLLs in VB .Net?

I want to create a DLL in VB .Net that can be used by other programming languages.  I realize the Framework will need to be installed in order for the DLL to run.  The DLL needs to expose functions, subroutines, classes, etc.  I created a new project as a Class Library, put a Public declared subroutine in it, but when I reference it from another VB .Net program, I cannot get to the subroutine and it is telling me it must be "Shared".  Do I need to make everything in the Class Library project shared?

I want all the items I deem necessary to be exposed to any program that uses this DLL.  Are there any steps published on how to do this?

Thanks in advance,

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.

If you want just call the subroutine without creating an instance of the class library, then the sub must be declared as shared.  For example, you can call String.Format without having an instance named "String."  

The other way to do it would be to put your subroutine in a public module instead of a class.

Right click your project in project explorer, select add > Module.  Make sure your module is declared "Public" as in:

Public Module GeneralRoutines
  Public Sub DoStuff()
   '...do stuff
  End Sub
End Module

Then as long as you have a reference to your dll in the client program, you will be able to access the DoStuff routine like this:



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
HAMMER33333Author Commented:

        If I go with the Module, which by the way is a great idea, can I then take the DLL and reference it in other non-.Net programs?  OR are there other things I need to do in order to make this possible?   I want this to be part of the functionality of this DLL.


>can I then take the DLL and reference it in other non-.Net programs?

non .NET programs?  You can use COM interop to call managed code from VB 6 or VC++...  I've never tried it.
Looking at that, I would think you would have to create a class that other clients could instantiate.
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.