justaphase
asked on
FoxPro, Sending array parameter to COM object
Hello Experts,
I'm working on a project using a COM Object that was made in .NET (doesn't really matter where is made i think).
I'm Trying to send an array with an object collection.
In debug seems ok, the array is there, the data collection is there, but the "objSendPaymentsOrderReque st.SetPaym ents" just doesn't want it.. and i know he wants an array collection.
The IntelliSense autocomplete doesn't work with the "CREATEOBJECT("Company.Biz .Treasury. ..")" methods, doesn't help either...
When i declare the array "DIMENSION Payments[1] AS Object", i really don't know what type i should put.. AS Object? AS Long? AS Custom? i really can't tell.
In the Object Browser of Visual FoxPro i'm able to explore the COM shared library of classes, but i can't really find the information of what kind of array or collection should i send...
When i declare the array as a Object (i think is the more correct approach) i get this error: "OLE error code 0x80070057: Unknown COM status code" in line 14 (objSendPaymentsOrderReque st.SetPaym ents(@Paym ents)).
I investigate and the 0x80070057 means "The parameter is incorrect". If i don't put nothing (no AS Type) or some other types i get the same error but with the "0x80020005" which means wrong type..
Is there any other way of doing this? Is there any other way to know what type of array i should send? Anything it could help...
Here's part of the code:
I'm working on a project using a COM Object that was made in .NET (doesn't really matter where is made i think).
I'm Trying to send an array with an object collection.
In debug seems ok, the array is there, the data collection is there, but the "objSendPaymentsOrderReque
The IntelliSense autocomplete doesn't work with the "CREATEOBJECT("Company.Biz
When i declare the array "DIMENSION Payments[1] AS Object", i really don't know what type i should put.. AS Object? AS Long? AS Custom? i really can't tell.
In the Object Browser of Visual FoxPro i'm able to explore the COM shared library of classes, but i can't really find the information of what kind of array or collection should i send...
When i declare the array as a Object (i think is the more correct approach) i get this error: "OLE error code 0x80070057: Unknown COM status code" in line 14 (objSendPaymentsOrderReque
I investigate and the 0x80070057 means "The parameter is incorrect". If i don't put nothing (no AS Type) or some other types i get the same error but with the "0x80020005" which means wrong type..
Is there any other way of doing this? Is there any other way to know what type of array i should send? Anything it could help...
Here's part of the code:
objSendPaymentsOrderRequest = CREATEOBJECT("Company.Biz.TreasuryMgt.MessageContracts.SendPaymentsOrderRequest")
objSendPaymentsOrderRequest.PayerName = "Company bla"
objSendPaymentsOrderRequest.PayerIban = "000702030001"
newPayment = CREATEOBJECT("Company.Biz.Treasury.DataContracts.PaymentOrder")
newPayment.Amount = 100
newPayment.PaymentId = 20
newPayment.RecipientIban = "00070203000875"
newPayment.RecipientName = "bla bla name"
DIMENSION Payments[1] AS Object && AS Long ?? && AS What? :(
Payments[1] = newPayment
objSendPaymentsOrderRequest.SetPayments(@Payments)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
It seems hints are similar but the solution is unclear... :-)
.T.
One obviuos solution, would be to write a wrapper to this COM OLE Server in whatever language can bind to it easier and let it be a wrapper or proxy or adapter (or whatever design pattern name you prefer) to the Foxpro usage, which accepts single parameters or a Foxpro Collection or an XML string and transforms that to the array needed.
Bye, Olaf.
PS: FYI the COMARRAY() was added to solve a COM array problem with AutoCAD automation. From time to time such a question occurs and normally COMARRAY does not help, it's quite generic, yet does only overcome problems with 1- vs 0-based indexing of the array elements, not problems with the array element values or types. Type conversion is a problem in COM, when it involves more than basic types.
Bye, Olaf.
PS: FYI the COMARRAY() was added to solve a COM array problem with AutoCAD automation. From time to time such a question occurs and normally COMARRAY does not help, it's quite generic, yet does only overcome problems with 1- vs 0-based indexing of the array elements, not problems with the array element values or types. Type conversion is a problem in COM, when it involves more than basic types.
ASKER
It's true.. it's very difficult for the .net COM accept foxpro arrays.
In our case i think the best way is to change the code in the COM in order to accept the array...
Thanks Olaf and pcelba, your comments were very helpful.
In our case i think the best way is to change the code in the COM in order to accept the array...
Thanks Olaf and pcelba, your comments were very helpful.