I'm trying to call Prolog script file from C# program using SWI Prolog. I downloaded the code package from github (using this link). But, when I'm trying to run the HelloWorldDemo program the following error occurs:
System.IO.FileNotFoundException: 'The specified module could not be found. (Exception from HRESULT: 0x8007007E)'
on Line 105 on the following code:
private static void LoadUnmanagedLibrary(string fileName)
{
if (_hLibrary == null)
{
_hLibrary = NativeMethods.LoadDll(fileName);
if (_hLibrary.IsInvalid)
{
int hr = Marshal.GetHRForLastWin32Error();
Marshal.ThrowExceptionForHR(hr); //here the error occurs
}
}
}
I tried many solutions on the Internet, for example, provide the swi path on setenviromentvariable but the error still same.
Here is the code of HelloWorldDemo.cs:
static void Main(string[] args)
{
Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Program Files\swipl\"); // I also used C:\Program Files\swipl\bin and didn't help too
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!");
}
}
So, how can I fix this issue?
Note: I'm using Win10 x64, visual studio 2017 community.
User contributions licensed under CC BY-SA 3.0