从 .Net 调用 FoxPro 代码

发布于 2024-08-04 07:46:53 字数 317 浏览 11 评论 0原文

谁能告诉我从 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

巡山小妖精 2024-08-11 07:46:53

我过去很幸运,采用了我想要公开的 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.

扛起拖把扫天下 2024-08-11 07:46:53

查看这篇有关 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.

忆离笙 2024-08-11 07:46:53

许多个月前,我曾经以 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;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文