?
Solved

How can i convert my program I have written into a dll and then use the dll in an exe to display the information.

Posted on 2005-05-04
7
Medium Priority
?
232 Views
Last Modified: 2010-04-17
I wrote a small application that gathers a bit of information about what user is on the computer, version of windows they are running, ip address and other diagnostic information.  I need to convert it into a dll and then use it in an exe to display the information.  How do i go about doing this?  (new to DLL's programming etc....)  hence the name!  ;)

Basically the steps i've been told i need to take are:

Create a new DLL project in .Net
Rewrite the code to present the information in the DLL.
Create a new EXE project in .Net
Add a reference to the DLL
Use the DLL.

... but i dont know the details of how to implement each.
0
Comment
Question by:TheRookie32
  • 4
  • 3
7 Comments
 
LVL 6

Author Comment

by:TheRookie32
ID: 13929502
I have done some research and been told to create a new class library project and then add my code.  Do i add my code from the solution explorer as "add existing item?" or what?...
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 1000 total points
ID: 13929567
Oh, let's see:

1) Create a new DLL project in .Net
Open a new project as a Class Library in say, VB.

2) Rewrite the code to present the information in the DLL.
Copy and paste from your other project.
Just make sure that properties and methods to be exposed are defined with scope "Public"
Build it (from the Build menu)

3) Create a new EXE project in .Net
I'm guessing you can handle this

4) Add a reference to the DLL
In the Solution Explorer window, right-click on Refernces and Add Reference...
Locate the above under the .Net tab, double-click it, and click OK

5) Use the DLL.
In code, define it and use it.
In VB, you can use something like:
   Dim obj as DLLProjectName.Module
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 13929582
>Do i add my code from the solution explorer as "add existing item?" or what?...

You should be able to do that in step 2, and it may convert it if from an older version.

Note that if you add existing item, it will probably reference that on the disk and NOT make a new working copy.
You may want to move the file (or a copy) to your new project folder before adding it.
0
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.

 
LVL 6

Author Comment

by:TheRookie32
ID: 13930534
sweet, there was a bit more to it than just copying the code... but thanks!

ie rewriting this where i put this value in a textbox:
txtDomainName.Text = System.Net.Dns.GetHostByName(sMachineName).HostName()

As this:

Public Shared ReadOnly Property DomainName()
            Get
                Return System.Net.Dns.GetHostByName(Environment.MachineName).HostName()
            End Get
        End Property
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 13930560
yes....obviously any references to control objects will need to be changed since a Class module typically has no interface.

If you want a class module with an interface, you should make a user-control instead.
0
 
LVL 6

Author Comment

by:TheRookie32
ID: 13931369
Ya i just ddnt know how to change em and it took a bit of digging to get that answer but thats the way it goes.  Anyway, i have listed another question related to this one, you know how to answer this?:

http://www.experts-exchange.com/Programming/Q_21413073.html
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 13931633
This seems to work, but is also similar to what's posted there:

friend function MyVersionNumber()
        const MY_FILENAME as String = "MYFILENAME.dll"
        return FileVersionInfo.GetVersionInfo(System.IO.Directory.GetCurrentDirectory() & "\" & MY_FILENAME).FileVersion)
end function

I think you can also replace the constant with a reflection call (instead of being hard-coded), but I can't seem to find that right now.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Screencast - Getting to Know the Pipeline

850 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