ActiveX Server not Being Recognized

VB6: For most of the time that I've worked with VB, I've built standard exe projects. I am now attempting to delve into greater things, although after getting my last problem fixed, I am wondering if it is worth it.

The project I am currently working on started out as a standard exe project. However, I have broken the data-centric classes into a spearate project and enabled it as an ActiveX EXE and the business objects into a project as an ActiveX dll.

I have been able to build the ActiveX exe project. I have the two projects in the same VB session within a project group. Now, when I try to complie the Business Object project, it gives me errors that the references to the data-centric objects stating: "User-defined type not defined"

My activeX exe is named HRPersist. In the case of the first error, I have the statements:

Public Sub Load(SearchText As String, SearchField As Long, Location As Long)
    Dim objPersist As cEmployeesPersist
    Set mcolDisplay = Nothing
    Set mcolDisplay = New Collection
    Set objPersist = CreateObject("HRServer.cEmployeesPersist")  ', PERSIST_SERVER)
'    Set objPersist = New cEmployeesPersist
    SetState objPersist.Fetch(SearchText, SearchField, Location)
    Set objPersist = Nothing
End Sub

The error references/highlights "objPersist As cEmployeesPersist" in the Dim objPersist As cEmployeesPersist statement.

Any ideas what I am doing wrong, or have failed to do?
LVL 15
Who is Participating?
if you press f2 to break up object browser from vb ide, do you see cEmployeesPersist?

If no, then make sure your class is set to multiuse from your activex exe
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you probably did not add the HRServer dll in the project references?

you might also change the line into this:
    Dim objPersist As Object
dbbishopAuthor Commented:
I won't be able to try your second suggestion until tomorrow. And yes, I did add the server (it is an exe, not a dll) to the project references.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

It seems that your ActiveX EXE is running on another computer as a remote ActiveX Server. But it won't work unless you register it on your client computer.

If so, you must copy your ActiveX Exe to the client computer (which the Standard Exe runs on), and run it once. Then you can delete it and your code above will work.
dbbishopAuthor Commented:
They are both on the same computer. I have not yet deployed it to another machine.
dbbishopAuthor Commented:
Got it. Somehow the Instancing got changed back to private. Not sure how it happened since I had copied everything into new directories and originally had all but two classes set to either MultiUse or PublicNotCreatable. Anyway got both the EXE and DLL to build.

I have another question. I am building all this based on Business Objects for VB6 by Rockford Lhotka. In his code, he is using late-binding for referencing the data-centric objects. As you can see, I originally had early-binding in my example above while designing everything within a single project. However, it has now been broken out into three seperate projects. Do I HAVE to use late-binding? Is there any reason I cannot keep the references early-bound?
>>Do I HAVE to use late-binding?


>>Is there any reason I cannot keep the references early-bound?

no, the only reason if you use cross reference
i.e. exe1 reference to exe2 and exe2 reference back to exe1

then you may use late binding
dbbishopAuthor Commented:
I don't think there is any reason I need to have the ActiveX EXE (data-centric server) reference the DLL (business object). All it does is accept calls and data from the dll and return data to it, but it does not initiate any communication to the dll.

Why do you think Rockford used late-binding in his examples?
no clue why but basically both shall work
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.