Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Implementation Problems
Message
De
01/02/2002 08:08:53
Lloyd Grant
Meridian Legal Systems
Buxton, Royaume Uni
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Implementation Problems
Divers
Thread ID:
00613911
Message ID:
00613911
Vues:
54
Hi All,

I have a problem with implementing interfaces. The situation is this:

I have implemented an interface between VFP 7 and LaserForms. Originally I used this code:

DEFINE CLASS clsLaserFormsApplicationImplements8627 AS session OLEPUBLIC

IMPLEMENTS __Application IN "C:\PROGRAM FILES\LASERFORM\LASERFORM\LFM32.EXE"

*-- Methods here matching the LaserForms interface
..
..
ENDDEFINE && clsLaserFormsApplicationImplements

and to create the implementation I would use this:

llSuccess = EVENTHANDLER( THIS.oLaserForms, THIS.oLaserFormsApplicationImplements )

This worked perfectly, but I wasn't happy with the hard coded path in the IMPLEMENTS statement. To avoid this problem I substituted the path for the LaserForm GUID so it now looks like this:

IMPLEMENTS __Document IN {D49FEDE0-5E7E-11D5-85E0-0010A4E8E4FF}#1.0

This line of code also functioned perfectly. Problem solved - or so I thought. When the project with this code was moved onto another machine you can buld an APP but not build an EXE. If you try to build an EXE you get the error

"Type Library"
"{D49FEDE0-5E7E-11D5-85E0-0010A4E8E4FF}#1.0 not found"

I took the DEFINE CLASS code and put it into a project of its own and built an in proceess DLL which I called "laserforms8627.dll". I then changed the code that instantiates the clsLaserFormsApplicationImplements8627 object and prefixed it with my DLL name. The 4th parameter "THIS" is passed so I can backlink from the implementation object.

THIS.oLaserFormsApplicationImplements = NEWOBJECT( "laserforms8627.clsLaserFormsApplicationImplements8627", "", "", THIS )

When you run this and instantiate the object who's definition is in the DLL it didn't seem to instantiate correctly. When you examine the object "THIS.oLaserFormsApplicationImplements" in the debug window you can not see all the properties and events. I put this down to the fact that it is in a DLL. With some experimentation I have shown to my satisfaction that you can run code that is based in the DLL OK. However when you run the project and attempt the interface implementation you get this error (from running the app)

"EventHandler object does not IMPLEMENT an interface"
cancel / suspect / ignore / help

The error occurs on this line of code

llSuccess = EVENTHANDLER( THIS.oLaserForms, THIS.oLaserFormsApplicationImplements )

It seems the DLL approach isn't going to solve my problem.

How can I solve this problem? I can't compile an EXE if the product that matches a GUID is not installed on that system. I have several builds of LaserForms in the office and the ones I have looked at have different GUID's. I have not investigated if the interface between the builds has changed as this is the only reason (as far as I am aware) that the GUID should be changed.

My preference is to be able to compile an EXE with the GUID in the code as it avoids the hard coded path problem. To do this currently I would require several versions of LaserForms to be installed. I was planning on having multiple class definitions for different GUID's and then instantiate the correct interface object at run time. The only other solution I can think of is to write out the class definition at run time to a .PRG and then instantiate the implemtation object based on that .PRG. This is do-able, but messy and it exposese part of the source code.

Have I misunderstood something with what I am doing? Have you any idea what I can do / test to fix this beast of a problem that I have?

Thanks!

Lloyd.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform