从 .Net 调用 FoxPro 代码
谁能告诉我从 .Net 3.51 应用程序调用 FoxPro 9 代码的最佳方法?
我有一个用 Fox 9 编写的遗留生产应用程序。我想公开尽可能多的逻辑和业务流程,以便我可以从 .Net 重用它。理想情况下,我希望以一种使其对 .Net 应用程序不可见的方式执行此操作,以便我可以稍后切换 Fox 代码并将其替换为 .Net 代码。
我想我可以在 Fox 中构建一个 COM DLL,然后从我的 .Net 项目中引用它,但我对此没有任何兴趣(编译时 Visual Studio 中出现各种错误)。我是否在这里错过了一个技巧,或者我是否需要做一些事情,比如构建一个 Fox Web 服务?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我过去很幸运,采用了我想要公开的 FoxPro 类,并使其继承自 Session 对象 -
DEFINE CLASS B AS SESSION OLEPUBLIC
然后构建 FoxPro DLL 并使用 RegSvr32 命令注册它。然后,在 Visual Studio 中,当您添加对项目的引用时,COM 对象应该显示在 COM 选项卡下。
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.
查看这篇有关 VFP 转换的文章 - 从 .Net 和 ASP 调用 VFP COM 组件。 Net - 它应该可以帮助您入门。
Have a look at this article on VFP Conversion - Calling VFP COM components from .Net and ASP.Net - it should get you started.
许多个月前,我曾经以 Com 的身份创建 FoxPro 类。正如克拉根建议的那样,将它们设置为 OLEPUBLIC,它将公开这些方法。出于许可目的,我曾经将它们添加到 Com+(在 Vista/Windows 7 中位于 C:\Windows\System32\comexp.msc 下)
然后在 .Net 中
使用 FoxProCom; (指向Com+中的com)
//连接到Com(使用FoxPro Com(项目名称-参见项目信息)和类名称
类型 ObjectType = Type.GetTypeFromProgID("FoxProComProj.FoxProComClass",Environment.MachineName.ToString(),true);
//激活通讯
对象 oDComObject = Activator.CreateInstance(ObjectType);
//实例化Com
FoxProCom.FoxProComClass oFoxCom = (FoxProCom.FoxProComClass) oDComObject;
oFoxCom.UseaOLEClass()
//清除 Com
oFoxCom = null;
Many moons ago, I used to create FoxPro classes as a Com. As Kragan has suggested make them OLEPUBLIC and it will expose the methods. For permission purposes I used to add them to Com+ (in Vista/Windows 7 this is under C:\Windows\System32\comexp.msc)
Then in .Net
using FoxProCom; (point to the 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);
//Instantiate Com
FoxProCom.FoxProComClass oFoxCom = (FoxProCom.FoxProComClass) oDComObject;
oFoxCom.UseaOLEClass()
//Clear Com
oFoxCom = null;