2

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?

4

3 回答 3

2

看看这篇关于 VFP Conversion - Calling VFP COM components from .Net 和 ASP.Net的文章- 它应该可以帮助您入门。

于 2009-09-08T13:08:14.443 回答
2

过去我很幸运,通过使用我想要公开的 foxpro 类并使其继承自 Session 对象 -

将 B 类定义为 Session OLEPUBLIC

然后构建 foxpro DLL 并使用 RegSvr32 命令注册它。然后在 Visual Studio 中,当您添加对项目的引用时,COM 对象应显示在 COM 选项卡下。

于 2009-09-08T21:58:14.697 回答
1

许多个月前,我曾经将 FoxPro 类创建为 Com。正如 Kragan 建议的那样,使它们成为 OLEPUBLIC 并且它将公开这些方法。出于许可目的,我曾经将它们添加到 Com+(在 Vista/Windows 7 中,它位于 C:\Windows\System32\comexp.msc 下)

然后在.Net中使用FoxProCom;(指向 Com+ 中的 com)

//连接到 Com(使用 FoxPro Com(项目名称 - 参见项目信息)和类名称 Type ObjectType = Type.GetTypeFromProgID("FoxProComProj.FoxProComClass",Environment.MachineName.ToString(),true);

//激活 Com 对象 oDComObject = Activator.CreateInstance(ObjectType);

//实例化 Com FoxProCom.FoxProComClass oFoxCom = (FoxProCom.FoxProComClass) oDComObject;

oFoxCom.UseaOLEClass()

//清除 Com oFoxCom = null;

于 2010-01-21T15:43:54.470 回答