DLLs in VB .Net?

Posted on 2005-03-11
Medium Priority
Last Modified: 2010-04-23
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,

Question by:HAMMER33333
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 38

Accepted Solution

PaulHews earned 2000 total points
ID: 13519029
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:



Author Comment

ID: 13519218

        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.


LVL 38

Expert Comment

ID: 13519309
>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.
LVL 38

Expert Comment

ID: 13519322
Looking at that, I would think you would have to create a class that other clients could instantiate.

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question