ОШИБКА: HRESULT: 0x8007007E System.IO.FileNotFoundException при интеграции с Прологом и C # - PullRequest
0 голосов
/ 25 августа 2018

Я пытаюсь вызвать файл скрипта Prolog из программы на C # с помощью SWI Prolog. Я скачал пакет кода с github (используя эту ссылку ). Но когда я пытаюсь запустить программу HelloWorldDemo, возникает следующая ошибка:

System.IO.FileNotFoundException: 'The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

в строке 105 по следующему коду:

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
            }
        }
    }

Я пробовал много решений в Интернете, например, предоставить swi-путь на setenviromentvariable, но ошибка все та же.

Вот код 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!");
            }
        }

Итак, как я могу исправить эту проблему?

Примечание: я использую Win10 x64, сообщество visual studio 2017.

...