Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting PRG CLASS to COM
Message
 
To
17/06/2011 16:57:01
Hong Yew
People Quest
Malaysia
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01515003
Message ID:
01515083
Views:
180
What are you trying to do exactly? It's pretty straight forward.

Create a FoxPro class that is exposed as a COM object:
DEFINE CLASS Foo as CUSTOM OLEPUBLIC

  FUNCTION HelloWorld(lcName)
  RETURN "Hello " + lcName + ". Time is: " + Time()

ENDDEFINE
Compile into either an MTDLL (for inprocess operation when using ASP.NET) or to an EXE (for out of process operation/DCOM).

From .NET you can then either:

* Import the type library and use the generated .NET wrapper class
* Use Reflection to load the COM type directly

The former is a little easier to do but is also limited in what is exposed (FoxPro doesn't expose nested objects for example). The latter lets you access anything, but it can be a bit more work.

If you're using .NET 4.0 to access the COM object everything becomes much easier as you can use the new Dynamic type to access COM properties - including child objects - directly.

There's more info in this article (which is pretty old and deals with pre-.NET 4.0 and ASP.NET scenarios), but gives you a basic understanding:

www.west-wind.com/presentations/VfpDotNetInterop/aspcominterop.asp

Hope this helps,

+++ Rick ---

>Hi all
>
>I am seeking some advice on the right approach to converting a PRG class to a VFP COM so that I can call it from my .NET app
>
>I need some guidelines on the right way to go about this conversion
>
>I would appreciate if you could share your experience in this area
>
>Best Regards and Many Thanks in Advance
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform