![]() |
Platforms, Frameworks & Libraries »
COM / COM+ »
COM
Intermediate
License: The Code Project Open License (CPOL)
Registering a COM DLL with VS 2005: A Walk-ThroughBy VB RocksThis article demonstrates how to register a COM DLL with Visual Studio 2005. |
VB 6, .NET, COM, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
In my previous article "Creating a COM DLL with VS 2005, A Walk-Through", we walked-through creating a COM DLL with Visual Studio 2005, using Visual Basic .NET.
In this article, we are going to walk-through registering our COM DLL.
If you are an experienced developer, and you've worked with DLLs before, you've probably already tried using RegSvr32, and have experienced some difficulties. If you're an experienced .NET developer, you may have tried using RegAsm, and have encountered some challenges there as well.
In this article, we are not going to look at the more complex approaches of registering a COM DLL. Instead, we are going to walk-through creating a VS 2005 Installer, which will both install and register our COM DLL for us, while providing a simple, professional tool to accomplish this task.
As a professional software developer, and an experienced COM DLL developer, I personally prefer using an Installer. Additionally, my clients appreciate it, because whenever they need to install a COM DLL, they are able to.
If you followed along with my previous article "Creating a COM DLL with VS 2005, A Walk-Through", then open that project now. If you did not follow my previous article, but have your own COM DLL that you have created, then open the project that contains that COM DLL now.
To begin with, let's add a new "Setup and Deployment" project to our solution:
The Add New Project window:

Now that the new "Library Installer" setup project has been added to the Solution, your Solution Explorer should look like the picture below. If Solution Explorer is not open, then open it by clicking on View menu | Solution Explorer.

Now that we have the installer added to the Solution, let's configure its properties.
Here's the Properties window:

The next thing we need to do is add the files that we want to the installer to install, which in this case is our COM DLL. The installer will not only install our COM DLL, but it will take care of registering it for us as well!
First, make sure your "File System" tab is visible. If it's not, follow these steps:
Next, configure the file system:


When you've added all of the folders, the file system should look like this:

Just a brief explanation: What we are doing is, we are telling the installer to install our COM DLL in the following location: C:\Program Files\Common Files\My Libraries.


When you're finished, it should look like this:

Finally Save and Build both projects.

We have finished our installer! Now we are ready to test it out!

When you run the Installer, observe the following:

We now have a registered COM DLL ready to be used in VB6. Let's go into VB6 and see how to use it.
Create a new VB6 Project:
Button to the Form, and double-click it to create the Click() event, and open the code window.Add a reference to our COM DLL:
Finally, in the Click() event for our Command Button, add code to utilize our COM DLL:
Private Sub Command1_Click()
Dim mcc As New MyComClass
mcc.DisplayMessage
End Sub
Here's the result of our test:

As you can see, creating a setup project to install and register your COM DLL is very easy with VS 2005! Additionally, it is very easy for anyone to use, and looks very professional!
I hope this article is helpful to you!
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 18 Aug 2008 Editor: Smitha Vijayan |
Copyright 2008 by VB Rocks Everything else Copyright © CodeProject, 1999-2009 Web18 | Advertise on the Code Project |