【问题标题】:interface prolog with C#与 C# 的接口序言
【发布时间】:2012-11-25 23:51:58
【问题描述】:

我尝试将 C# 与 prolog 接口 我用过这个链接: enter link description here

我已添加 SwiPlCs.dll 作为对我的项目的引用,然后使用文档中的第一个代码

using System;
using SbsSW.SwiPlCs;


namespace HelloWorldDemo

{

class Program
{
    static void Main(string[] args)
    {
        //Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"the_PATH_to_boot32.prc");
        if (!PlEngine.IsInitialized)
        {
            String[] param = { "-q" };  // suppressing informational and banner messages
            PlEngine.Initialize(param);
            PlQuery.PlCall("assert(father(martin, inka))");
            PlQuery.PlCall("assert(father(uwe, gloria))");
            PlQuery.PlCall("assert(father(uwe, melanie))");
            PlQuery.PlCall("assert(father(uwe, ayala))");
            using (PlQuery q = new PlQuery("father(P, C), atomic_list_concat([P,' is_father_of ',C], L)"))
            {
                foreach (PlQueryVariables v in q.SolutionVariables)
                    Console.WriteLine(v["L"].ToString());

                Console.WriteLine("all child's from uwe:");
                q.Variables["P"].Unify("uwe");
                foreach (PlQueryVariables v in q.SolutionVariables)
                    Console.WriteLine(v["C"].ToString());
            }
            PlEngine.PlCleanup();
            Console.WriteLine("finshed!");
        }
    }
}

}

但总是有例外..据说:

找不到指定的模块。 (来自 HRESULT 的异常:0x8007007E

他们在 SWI-prolog 中提到了这个错误:

如果找不到 libswipl.dll 或其依赖项之一,您将收到类似的错误 System.IO.FileNotFoundException: Das angegebene Modul wurde nicht gefunden。 (Ausnahme von HRESULT: 0x8007007E)

我已将 libswipl.dll 从程序 bin 复制到我项目中的 bin/debug 文件夹,但问题仍然相同。

我该怎么办?? 谢谢

【问题讨论】:

    标签: c# prolog


    【解决方案1】:

    您是否声明了 SWI_HOME_DIR ?应该指向 c`\Program Files\pl

    C# 接口不适用于 Windows 7 64 位、Visual Studio 2010 专业版。 似乎是一个错误,Uwe Lesta 应该尽快修复这个错误。

    【讨论】:

    • Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Program Files\swipl\bin");但也没有工作我有 vs2010 我的电脑是 32 位的
    • 您的 SWI-Prolog 版本是什么? swipl.exe 和 dll 的名称在 5.10.0 版本发生了变化
    • 你用这个版本的dll:SwiPlCs_1.1.60301.0 ?
    【解决方案2】:

    我遇到了同样的错误,所以我下载了 SwiPlCs_1.1.60301.0 并将 SwiPlCs64.dll 的名称更改为 SwiPlCs.dll 并在 Visual Studio 中将其添加为参考并且它有效:) PS:我正在使用 Visual Studio 2010 和 Windows 7 64 位。 希望这会有所帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 2021-05-24
      • 2021-07-17
      • 2010-09-06
      • 1970-01-01
      • 2011-12-23
      • 1970-01-01
      相关资源
      最近更新 更多