Search code examples
.netfoxpro

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 that is written in Fox 9. I want to expose as much of the logic and business processes as I can so that I can reuse it from .Net. Ideally I want to do this in a way which makes it invisible to the .Net application so that I can switch out the Fox code and replace it with .Net code later.

I was thinking that I could just build a COM DLL in Fox and then reference it from my .Net project but I'm not having any joy with that (various errors in Visual Studio when I compile). Am I missing a trick here or do I need to do something like build a Fox web service?


Solution

  • I've had luck in the past by taking the foxpro class I wan to expose and making it inherit from the Session object -

    DEFINE CLASS B AS SESSION OLEPUBLIC

    Then build the foxpro DLL and register it with the RegSvr32 command. Then in Visual Studio the COM object should show up under the COM tab when you add references to your project.