簡體   English   中英

將Microsoft .NET(C#/ F#)與SWI-Prolog接口

[英]Interfacing Microsoft .NET ( C# / F# ) with SWI-Prolog

我將Prolog連接到C#時遇到問題。

Visual Studio出現以下錯誤:

“ SwiPlCs.dll中發生了'System.IO.FileNotFoundException'類型的未處理的異常”

我真的不知道該如何處理。

我認為它來自我在代碼中給出的路徑:

using System;
using SbsSW.SwiPlCs;

namespace ptest
{
    class Program
    {
        static void Main(string[] args)
        {
            //Environment.SetEnvironmentVariable(@"C:\Program Files\swipl", @"C:\Program Files\swipl\boot64.prc");  // or boot64.prc
            var curPath = Environment.GetEnvironmentVariable("C:\\Program Files\\swipl\\bin");
            Environment.SetEnvironmentVariable(@"C:\Program Files\swipl\bin", @"C:\Program Files\swipl\boot;C:\Program Files\swipl;" + curPath);

            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 (var 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 children from uwe:");
                    q.Variables["P"].Unify("uwe");
                    foreach (PlQueryVariables v in q.SolutionVariables)
                        Console.WriteLine(v["C"].ToString());
                }
                PlEngine.PlCleanup();
                Console.WriteLine("finshed!");
            }
        }
    }
}

請幫我。 非常感謝你。

我認為SWI_Prolog的最新版本存在問題。 嘗試在C:/ Program Files(x86)中為Microsoft Windows(32位)安裝舊版本的SWI-Prolog 6.6.1,並使用SwiPlCs_1.1.60301.0.zip 在Visual Studio中添加對SwiPlCs.dll的引用。 它將工作IA :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM