Prolog Integration with C #

I am new to Prolog and C #. When I try to integrate Prolog with C #, I find some errors,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SbsSW.SwiPlCs;


namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
           // Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"the_PATH_to_boot32.prc");  // or boot64.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 (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("finished!");
            }
        }
    }
}

It does not work, before starting I added the SwiPlCs.dll link. But it shows the error "FileNotFoundException was unhandled, the specified module was not found. (Exception from HRESULT: 0x8007007E)."

So can someone help me fix this error?

I got this encoding here

+4
source share
1 answer

The link you provided contains a full explanation of this error:

libswipl.dll , , System.IO.FileNotFoundException: Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E)

:

SWI-Prolog: [FATAL ERROR:
  Could not find system resources]`  
  Failed to release stacks

, SWI_HOME_DIR, SWI-Prolog FAQ FindResources , PlEngine.Initialize.

Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"the_PATH_to_boot32.prc");

, the_PATH_to_boot32.prc. FAQ:

Windows libswipl.dll (.. ) bin %PATH%.

- putenv() PL_initialise().

...;
putenv("SWI_HOME_DIR=C:\\Program Files\\swipl");
if ( PL_initialise(argc, argv) )
  PL_halt(1);
...

( swipl-ld cat (Unix)) putenv().

+4

All Articles