Calling FoxPro Code from .Net

Can anyone tell me the best way to call FoxPro 9 code from a .Net 3.51 application?

I have a legacy production application written in Fox 9. I want to expose as many logic and business processes as possible so that I can reuse it from .Net. Ideally, I want to do it in a way that makes it invisible to the .Net application so that I can turn off the Fox code and replace it with .Net code later.

I thought I could just create a COM DLL in Fox and then reference it from my .Net project, but I'm not happy with that (various compilation errors in Visual Studio). Am I missing a trick here or do I need to do something like create a Fox web service?


source to share

3 answers

I have had luck in the past by taking the foxpro class I wan to expose and inherit from the Session object -


Then create the foxpro DLL and register it using the RegSvr32 command. Then in Visual Studio, the COM object should appear on the COM tab when you add references to your project.



Take a look at this article on VFP Conversion - Calling VFP COM Components from .Net and ASP.Net - it should get you started.



Many moons ago I used to create FoxPro classes as Com. Since Kragan suggested to make them OLEPUBLIC and he will expose the methods. For permission purposes, I used them to add to Com + (on Vista / Windows 7, this is under C: \ Windows \ System32 \ comexp.msc)

Then in .Net using FoxProCom; (point to com in Com +)

// Connect to Com (using FoxPro Com (project name - see project information) and class name Type ObjectType = Type.GetTypeFromProgID ("FoxProComProj.FoxProComClass", Environment.MachineName.ToString (), true);

// Activate Com Object oDComObject = Activator.CreateInstance (ObjectType);

// Instant Com FoxProCom.FoxProComClass oFoxCom = (FoxProCom.FoxProComClass) oDComObject;

oFoxCom.UseaOLEClass ()

// Clear Com oFoxCom = null;



All Articles