Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DCOM and ActiveX components

1 view
Skip to first unread message

Klerman Gutiérrez

unread,
Dec 5, 1997, 3:00:00 AM12/5/97
to

Hello.
I'm writing a small program with VB5.0 enterprise edition and I've found
one problem I can't solve for more than I look in the documentation.
I have one client module (normal exe) and one server component (activex
exe).
The server is installed in a NT 4.0 machine and configured with dcomcnfg.
The client is running in a Win 95 machine.
When I run both the client and the server in the programming machine, all
works as expected, both in the VB environment and after being compiled.
But if I try to run the server and the client in the separate machines I
described, I get the following error in the client machine "Run time error
429: ActiveX component can´t create object". It happens when the client
tries to open the first instance of a class which resides in the server
app.
I have followed step by step the recomendations found in the VB
documentation and in the Q161837 KB article.
The key HKEY_LOCAL_MACHINE\Software\Microsoft\OLE\DCOM in the server is set
to enable it.

I'd really appreciate if someone told me how to get this program to run.
Many thanks in advance.

Klerman,


David Barker

unread,
Dec 7, 1997, 3:00:00 AM12/7/97
to

There is a recent description on how to do this on the Microsoft knowledge
base (I think sometime in October). It is quite tricky, but certainly can be
done.
If you can't find it then eMail me at david.b...@virgin.net and I'll
explain it in all it's gory details
(It's late and I'm tired, otherwise I'd do it now.)

Quick tip - BOTH the client and the server must be ActiveX components.

David Barker

Klerman Gutiérrez wrote in message <01bd01eb$db7a2740$0100007f@homepc>...

David Barker

unread,
Dec 8, 1997, 3:00:00 AM12/8/97
to

DCOM across a network – the gory details
You have written your new 3-tiered application. You have a server that
raises events, and an interface that reacts to them. You have tested it on
your development network, with the interface and business objects on one PC,
because your company won’t pay for another PC (“You already have the most
powerful PC in the company, AND your own server – what do you need another
PC for???”). It works fine.
You install the software on your users’ PCs, set up the business object
server and the SQL server, start it up and…
“Cannot create ActiveX object!”
Sounds familiar…

Here is how to set it up.

Step 1
Project Properties

First what they don’t tell you. COM can work between a standard EXE and an
ActiveX component. DCOM only works between ActiveX EXE standalones and
components.
Therefore you have to make your interface an ActiveX EXE – ie
In your interface project, go to the Project > Properties menu option. In
the general tab, set the Project Type to “ActiveX EXE”. Then in the
component tab, set the Start Mode to “Standalone”. You must have at least
one public Class Module. It doesn’t have to do anything, but is vital later
on. (I think this also means that you can’t have a startup form – you must
have a module with a Sub Main() that shows the form.)

(Dear Mr Gates – Why can't you make this a bit simpler.)

Your server is probably set up correctly – ie Project Type of “ActiveX EXE”
and Start Mode of “ActiveX Component”. Make sure the Remote Server Files
option is checked.

(NB I never use project groups – I can’t work them out.)


Step 2
Compile the Projects.

Compile the Server first. Compile as normal. (I always use Compile To Native
Code, Optimise for Fast Code, and nothing else.)

Close the Server project and open the interface. Remove all references to
the Active X server components, and then reference them again. Make sure
that you are referencing the EXE you have just created, and not an old type
library in your WINNT/SYSTEM32 directory. This just makes sure that the
references are up to date (I have had problems if I don’t do this). Then
compile as normal.


Step 3
Create the Setup disks, using the Setup wizard.

Create the server first. There should be nothing unusual about this. I never
bother with dependency files - it seems to work anyway. Make sure that the
Shared ActiveX Application screen “Install as Shared Component” option is
selected, and Remote Automation “No”.

Then create the Interface Setup. It will reference your Server ActiveX EXE
in the “ActiveX Server Components” screen. Deselect the EXE, then press the
Add Remote button.
Browse the directory where the server project executable lives, and you
should see a .VBR file for your server. Select this (This is the Remote
Server file you created in the Project Properties for the Server).
You will then get the Remote Connection Details screen. Ensure that the
Remote Transport option is set to DCOM and enter the Computer Name for the
PC that the server component will run on. (You can change this later when
you configure the DCOM settings.)
In the Shared ActiveX Application screen, select the Install as StandAlone
application, and Remote Automation “No”.
I ALWAYS do the setup based on the Project, and never use a template. I have
had problems before while using templates, and rebuilding the Setup without
the template fixed the problem.


Step 4
Uninstalling any previous versions.

Use the Contol Panel Add/Remove Programs to uninstall any previous versions
of the software (both client and server)

Then clean up the Registry. This is a real pain in the neck, but I can never
get anything to work unless I do it. I use REGEDIT on NT4 to search for any
keys that contain the project names or Class names of either the server or
the client. I delete any keys that I find.
You also have to find and delete the DCOMCNFG keys that give the location
and permissioning of the Server objects. One way is to use DCOMCNFG to
change the server name to something silly, and then use REGEDIT to search
for this Name, and then delete the Keys.
Run DCOMDNFG and make sure that all Client and Server classes no longer
appear.
(Dear Mr Gates – why can’t Uninstall remove ALL traces of a program??)


Step 5
Install and permission the server

Run the Setup program for the server software on the server PC. (Make sure
that you have a login that can change all the registry keys)

Run DCOMCNFG.
The first time you run DCOMCNFG set the following defaults:
On the Default Properties tab, enable DCOM, set the Default Authentication
Level to “None”, and set the Default Impersonation Level to “Impersonate”
On the Default Security tab, set the following:
Default Access Permissions
Everyone Allow Access
INTERACTIVE Allow Access
SYSTEM Allow Access
Default Launch Permissions
Everyone Allow Launch
INTERACTIVE Allow Launch
SYSTEM Allow Launch
Default Configuration Permissions
CREATOR OWNER Full Control
Everyone Read
INTERACTIVE Full Control
SYSTEM Full Control

Then every time you reinstall the software:
For all the Publicly Creatable classes you must set the following:
Location Tab
Select “Run the application on this computer”
Security Tab
Select the custom permissions for each option and ensure that the
permissions are set to the same as the default. (This might be overkill, but
I see no harm in checking)
Identity Tab
The Interactive User (This is very important)

Log back in to whatever the server is normally logged in as. I think that
you must be logged in as something, since the server software runs under the
login of the interactive user. If you are worried about security, you can
always CTRL-ALT-DELETE on NT to lock the PC. Don’t ask me about Win95 – I
only ever use it to play games.


Step 6
Install and permission the Client

Run the setup program for the client software on the client PC. (Make sure
that you have a login that can change all the registry keys)
Run DCOMCNFG.
If it is the first time you have run DCOMCNFG on the client, make sure that
all the defaults are set up the same as the server.
In the list of applications, you should find the Class module that you put
in the Client application.
[This is why most people get stuck trying DCOM, especially if you use
Events. If an event is fired by the server, it makes a DCOM call to the
client (ie the Sever becomes the client, and the client becomes a server.)
Therefore you must configure the client to be a server. Therefore the client
must be an ActiveX application, and it must have a public class that
DCOMCNFG can permission. You don’t need to have the event handling procedure
in this class – it can just be a blank class module.]
Configure this class in exactly the same way as the server

You should also find the server listed in the applications tab. Select it
and ensure that the Location is correct.
Log back in as whatever your users normally log in as.


Step 7
Run the client application – it should work.


Tips
I usually give myself 2 hours from starting the compilation to getting the
software installed and running (with 2 clients)

Don’t try and cut out any steps unless you have time to experiment – when
you are clearing out the registry for the fifth time that evening, it is not
funny.

Be careful when setting the standalone options, especially in the setup
wizard. I think the only difference is the location of the executable, but
it means that any shortcuts won’t work.

Keep checking the Microsoft Knowledge Base for updated articles – they know
a lot more about DCOM than me (At least I hope they do). I usually search
for DCOM and Event and Visual Basic.

Try to get a simple Client and Server running before it becomes a critical
part of your project. There is a good example in the Microsoft Knowledge
Base which is where I got all the DCOMCNFG settings from.

You can run the Client interface in the IDE by installing a copy of the
client interface on the PC and then referencing the .TLB file for the server
in the WINNT/SYSTEM32 directory.

You can’t run the server in the IDE – DCOMDNFG can’t reference it.

Klerman Gutiérrez

unread,
Dec 10, 1997, 3:00:00 AM12/10/97
to

Hello David !.
Thanks a million for your help !!!.
I will certainly make good use of all this information.

Regards,
Klerman


0 new messages