Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DLLs in VB .Net?

Posted on 2005-03-11
4
Medium Priority
?
267 Views
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,

Hammer
0
Comment
Question by:HAMMER33333
  • 3
4 Comments
 
LVL 38

Accepted Solution

by:
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:

GeneralRoutines.DoStuff

0
 

Author Comment

by:HAMMER33333
ID: 13519218
Paul,

        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.

Thanks,

Hammer
0
 
LVL 38

Expert Comment

by:PaulHews
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.
http://www.programmersheaven.com/articles/arun/interop2.htm
0
 
LVL 38

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline

580 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