Go Premium for a chance to win a PS4. Enter to Win


DCOM Question!!!

Posted on 2002-07-17
Medium Priority
Last Modified: 2010-05-02
Hi, I am trying to learn DCOM using VB

I made very simple ActiveX EXE

below is my stupid server.

Public Sub Display(Message As String)

    MsgBox Message
End Sub

This is the only function that DCOM server has

below is my client code.

Private Sub Command1_Click()
   Dim a As DCom_Server.Class1

   Set a = CreateObject("DCom_Server.Class1", "grand-blue")
   a.Display "Hello"
End Sub

It works on the local machine, which named "grand-blue", but it does not work on a remote machine.

I get an error saying "Run Time Error 464,  Class not registered on local machine"

I added the reference of that class to my remote client machine from Project/References menu by browsing to "grand-blue" machine where the exe file exist.

I am using the BOOK called VB COM bu Thomas Lewis.  The book shows very simple client example like above and it does not explain how to use DCOM object from remot machine.

How do I make an instance of a class in a remote activex exe DCOM server using VB??
Question by:string6

Expert Comment

ID: 7161147
you must use "administrator tool\Com commponents" (I'm not sure which name it is) make a package in server, then distribute this package to client, an install this package in client use same tool.
because this tool is diffrent in diffrent Windowns version, so you need found it yourself, I can not explain detail.

In WinNT: Win NT 4.0 Option Pack\Microsoft Transaction Server\Transaction Server Explorer
LVL 26

Expert Comment

ID: 7161888
You have to register your simple ActiveX EXE on both machine. On thing you have to set your simple ActiveX EXE
as binary compatability on Project->properties->component tab.

If it still doesn't work, you need to run dcomcnfg.exe on remote machine to allow 'specifiy user' to launch it.
LVL 18

Accepted Solution

mdougan earned 400 total points
ID: 7162058
It's actually a lot more complicated than that.  DCOM makes the registration issues very difficult, but let me try to explain.

When you compile your Server program on your local development machine, the registry gets a lot of entries that associate the GUIDs of your Server program with the actual EXE that contains them.  So, when the Client program does a CreateObject, the registry knows to go find that EXE and run it.

Now, when you want to install the Server Program on a remote machine, the Program has to be installed there in such a way as to make the proper registry entries there (so, you need to create an install program with something like the Package and Deployment Wizard and then "install" your server program on the server).  

Then, you will write your client program.  During development, if you use CreateObject, it will likely find the copy of the Server EXE that you compiled on your development machine.  That is fine for development.  However, when you build the installation program for your client program, you will need to tell the installation program that you want to use a Remote Component, and it will ask you to locate the .TLB file for that component (I think that is the extension).  This file was created when you built the install program for your Server EXE.

If all goes well, whenever you install the client program, you will be prompted for the name of the server where the Server EXE is installed and logon id to use when connecting to it.

Now, there is a slight shortcut.  When you are developing your client program, and you do the CreateObject and it finds the local version of your Server EXE, you can go into the registry and add or change a few of the entries so that it doesn't look on your local machine for the EXE but on a remote machine.  This will only work on a machine where you have either compiled the Server EXE or one where you have installed the Server EXE (because all of the registry entries will have been made).

I have a document somewhere that details the registry entries that you need to change, but I might have gotten them from the same book you have...

Now, after all of the registry entries are made/changed, and your client program can find the Server EXE on the remote machine, it still may not be able to run it!  That is because DCOM has a pretty complicated authentication scheme.

So, after all of the installs/registry entries are complete, then on both the Client computer and the Server computer you have to run the program called dcomcfg.EXE  Look through the list of components that it finds until you find your server EXE (it might only list it by the CLSID, so, you need to know what this is for your Server's Class)  Then, you can grant Execute permissions to the user you will be logging in as on your client computer.  Run dcomcfg on the client computer as well.

Now, after all of that, you may be discouraged with DCOM.  I encourage you to look towards using COM+ instead.  If your server is a Windows 2000 machine, then COM+ takes all of the headaches out of the registrations issues.  When you have your component installed and running under the W2K Component Manager, then you can export a .MSI file, and then take this .MSI file to any client computer (the client has to have the Windows Installer program installed), and just double-click on the .MSI file and it makes all the necessary registry entries.

Author Comment

ID: 7162101
to mdougan;

God, your expaination was so detail.  Thank you very much.
I feel really bad that I can give you only 100 points.  Thats all I have now..........

Thank you very much again.
LVL 18

Expert Comment

ID: 7163086
No problem.  Let me know if you have more trouble getting it to work.  

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

885 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