如何将配置从 Visual FoxPro 应用程序传递到 AppDomain

How to pass configuration to AppDomain from Visual FoxPro application

我在 C# 中使 COM 可见。NET DLL 引用外部 DLL,外部 DLL 从当前 AppDomain 读取 app.config。但是,我的 DLL 是从 Visual FoxPro 9 调用的,因此它缺少项目中 app.config 的内容。

Foxpro 在 .NET 中有类似 app.config 的东西吗?我只需要通过 FoxPro 的 AppDomain 将配置传递给外部库。

VFP 不像 .Net 那样有单独的 AppDomain。但是,如果您将 DLL 放在 VFP 可执行文件所在的同一文件夹中,那么您的 AppDomain.CurrentDomain.BaseDirectory 就是 VFP 可执行文件所在的文件夹(换言之,它与 VFP 的 justpath(Application.ServerName) 相同)。即:

string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "app.config");

另外 App.config 只是一个普通的 xml 文件。您可以在 VFP 中随意阅读和处理它的内容。

VPF 创建 .exe 文件。只需创建内容与 dll.config.

相同的 .exe.config 文件