Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can VFP receive an object variable returned from DotNet program ? 1

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Dear Team!

I am using a DLL written (written mysefl) in DotNet to access an API. My base program is in VFP which utilises the DLL methods.

So, now I need an object variable (as I need multiple parameter values returned) to be returned from my DotNet program.
In DotNet it's okay to have final values in an object. But, if I return that, how can VFP store that to a suitable type variable.
Is there a way? Or, is the solution much more simpler that I think?

Thanks,
Rajesh
 
Rick Strahl has an article that explains how to do this. See
If I've understood the article correctly (and I'm no expert), this is just a matter of creating an object in VFP; passing it to your .Net method; that method then fills the properties of the object with the values to be returned; and you access those properties in VFP.

Rick explains it better than I can. Look at the above article, especially the section headed, "Passing Complex types between Visual FoxPro and .NET".

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
Great! You're showing me the right direction I trust.
Will check that for sure.
Thank you,
Rajesh
 
Hi Mike,

What I want is to return an object from DotNet and to receive it at VFP end (to process it further).

I just had rapid go through of Rick's article that you suggested. When I saw a portion mentioning that dotnet can directly expose its object to VFP, I decided to check. The return value from DotNet is a json in fact which has few properties including an array property. So in DotNet, using JavaScripSerializer, I converted that into an object and simply returned it. It was perfectly received at my VFP end without any further modification. It was like,

Code:
lo = DotNetObj.myMethod('1','222333')

where lo is just a simple VFP variable. In Watch window I can perfectly see it as an object and can refer to its properties including the array property and its individual elements.

So, in my VFP, there is nothing extra to be done to achieve what I wanted.

Alternatively, I thought instead of returning an object if I return the json as it as, I can parse it here in VFP using 'nfJson'.

Thanks,
Rajesh
 
Mike said:
As I said,I am not an expert, but am willing to learn.
By the way Mike, I am surprised and wondering why a person like you should say that!
I have been seeing some of the straight forward, simple and to the point kind of answers, advises & suggestions from you for quite some time. Only experts can present things in that way, isn't it? (I am asking others in this team :))

Thank you very much for your valuable suggetions dear!

Rajesh
 
I agree with Mike's comment, I too learn and willing to learn every day. I don't know everything and if I need to use something new, I research until I'm comfortable with the subject.



If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top