Information générale
Catégorie:
COM/DCOM et OLE Automation
>>Direct Array parameters don't work well over COM because VFP formats these things in ways that are difficult for COM to handle. However, you can wrap arrays into properties of objects and pass them around pretty easily that way... <<
Hi Rick!
That's the approach I tried, My COM+ code was ;
DEFINE CLASS ObjectTest AS Session OLEPUBLIC
FUNCTION PopObject( oLink AS Object) AS Object
LOCAL lnResult,loMtx,loContext
*) Create a reference to MTS
loMtx=CREATEOBJECT("MTXAS.AppServer.1")
*) Create a reference to the Context object?????
loContext=loMtx.GetObjectContext()
oLink.AddProperty("TestProperty")
oLink.TestProperty="My Test Value"
oLink.nValue=ALEN(oLink.aTest) && Property created in calling prog
DIMENSION oLink.aTest[5]
FOR lnk=1 TO 5
oLink.aTest[lnk]=CHR(64+lnk)
ENDFOR
*) Commit the transaction & tell MTS we are done (like a kipper)
loContext.SetComplete()
RETURN oLink
ENDFUNC
ENDDEFINE
Then My Test Prog is ;
oTest=CREATEOBJECT("ComPlus.ObjectTest")
oMyObject=CREATEOBJECT("Custom")
oMyObject.AddProperty("nValue")
oMyObject.nValue=999
oMyObject.AddProperty("aTest[1,1]")
DIMENSION oMyObject.aTest[2]
oMyObject.aTest[1]="Z"
oMyObject.aTest[2]="Z"
oMyObject=oTest.PopObject(@oMyObject)
FOR lnk=1 TO ALEN(oMyObject.aTest)
?lnk, oMyObject.aTest[lnk]
ENDFOR
When I Build an MT DLL and run my Test I get a OLE iDispath error on the line
oLink.nValue=ALEN(oLink.aTest)
"Data type mismatch", if I remove that line then I get a OLE iDispatch error on the line
DIMENSION oLink.aTest[5]
"Property aTest not found".
What am I doing wrong?
I also have a follow up question! With DCOM I used CreateObjectEX() so that I could create instances of my data object from any one of 10 data servers (accross a WAN). How does COM+ know which server I want? As I understand it I only issue a CreateObject() and COM+ does the rest, but if I have one object with 10 possible locations how do I direct it??
Gary.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement