Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing arrays to .NET and getting arrays back
Message
De
02/05/2011 12:19:40
 
 
À
02/05/2011 12:11:17
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01509041
Message ID:
01509046
Vues:
52
>>I have built a webservice wrapper in C# for VFP to eat. Works great. All my exposed methods are receiving and returning to and from VFP as expected - except arrays
>>
>>I think I need a refresher on the nuances of passing arrays in and out. Because of lack of strong typing, I assume the .NET incoming param must be object[] or object[,]
>>
>>I am currently trying to pass in a vfp @arrparam where arrparam is dime arrayparam[4] of strings. I would like to get back ids[4,2] with strings and integers.
>>
>>I could also pass in a 2 dime array by reference if I could figure out how to pass it back.
>>
>>If my object is lows, besides
>>
>>comarray(lows,0) to get the array to pass in 0 based what are the other tricks I should know about this?
>>
>>The method works fine in my .NET test harness
>>
>>
>>    public object[,] FindIdsByEmails(object[] emailarray)
>>        {
>>            int emailslen = emailarray.Length;
>>            object[,] returnarray = new object[emailslen, 2];
>>            for (int i = 0; i < emailslen; i++)
>>            {
>>                string email = (string)emailarray[i];
>>                long? id = this.FindIdByEmail(email);
>>                returnarray[i, 0] = email;
>>                if (id != null)
>>                {
>>                    returnarray[i, 1] = id;
>>                }
>>                else
>>                {
>>                    returnarray[i, 1] = 00000;
>>                }
>>            }
>>            return returnarray;
>>        }
>>
>>
>>But this VFP test prg gets me an error that "Function argument value, type or count is invalid."
>>
>>
>>CD "c:\users\pagan\documents\visual studio 2010\projects\glwebservice\glwebservice\bin\debug"
>>ACTIVATE WINDOW watch
>>lows = CREATEOBJECT("glwebservice.glclient")
>>lows.login("xxxxxx@xxxxx.org", "password", "<security key")
>>
>>DIMENSION foo(4)
>>
>>foo(1)="dan@primarydatasolutions.com"
>>foo(2)="charleshankey@f1tech.com"
>>foo(3) = "raferris@hsonline.net"
>>foo(4) = "foo@foo.net"
>>DIMENSION ids(4,2)
>>
>>comarray(lows,0)
>>
>>* here's where I get the error
>>
>>ids = lows.FindIdsByEmails(@foo)  
>>
>>lows.logout
>>lows = null
>>
>>RETURN
>>
>>
>>
>>
>>Suggestions, hints, pointing to docs all appreciated.
>
>
>See if Message #675527 helps...

That doesn't seem to do it. I'm not passing the array to the webservice but to a .NET dll ( the webservice isn't involved at this points - issue would be the same if this were just vfp-.net interop.

The Rick link I posted at the top also doesn't help as he his just talking about how to redimension .net side arrays.

My issue is :

How do I get an array back from .NET. ?

I can pass in an array successfully ( I do that in another method ) receiving it as an object[,] on the .net side.

But how do I pass an array back? If it is an option I would be fine with treating the array param by reference or I could create a new array entirely and pass that back.

Just missing something here ...


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform