×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can VFP receive an object variable returned from DotNet program ?

Can VFP receive an object variable returned from DotNet program ?

Can VFP receive an object variable returned from DotNet program ?

(OP)
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

RE: Can VFP receive an object variable returned from DotNet program ?

Rick Strahl has an article that explains how to do this. See https://www.codemag.com/Article/060014/Passing-obj...

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

RE: Can VFP receive an object variable returned from DotNet program ?

(OP)
Mike,
Great! You're showing me the right direction I trust.
Will check that for sure.
Thank you,
Rajesh

RE: Can VFP receive an object variable returned from DotNet program ?

Let us know how it works out, Rajesh. As I said,I am not an expert, but am willing to learn.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Can VFP receive an object variable returned from DotNet program ?

(OP)
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

RE: Can VFP receive an object variable returned from DotNet program ?

(OP)

Quote (Mike )

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 smile)

Thank you very much for your valuable suggetions dear!

Rajesh

RE: Can VFP receive an object variable returned from DotNet program ?

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: How to get the best response from the forum first.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close