【问题标题】:Prolog with c# visual studio 13带有 c# Visual Studio 13 的 Prolog
【发布时间】:2015-09-18 11:16:27
【问题描述】:

使用 Visual Studio 13 使用 c# 进行 Prolog 但是这个例外有一个问题: mscorlib.dll 中出现“System.IO.FileNotFoundException”类型的未处理异常

附加信息:找不到指定的模块。 (HRESULT 异常:0x8007007E)

 using System;
 using SbsSW.SwiPlCs;

    namespace ConsoleApplication35
    {
        class Program
        {
            static void Main(string[] args)
            {

                Environment.SetEnvironmentVariable(@"D:\Prolog\swipl", @"D:\Prolog\swipl\boot");
                if (!PlEngine.IsInitialized)
                {
                    String[] param = { "-q" }; 
                    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!");
                }
            }
        }
    }

【问题讨论】:

    标签: c# visual-studio-2013 prolog


    【解决方案1】:

    我认为您的意思是设置PATH 环境变量,您的代码需要更改如下:

    var curPath = Environment.GetEnvironmentVariable("PATH");  
    Environment.SetEnvironmentVariable(@"PATH", @"D:\Prolog\swipl\boot;D:\Prolog\swipl;" + curPath );
    

    【讨论】:

    • 不会覆盖路径变量的全部内容吗?对我来说似乎是个坏主意。
    • 我可能会尝试获取路径变量,看看它是否包含我的文件夹,如果没有,那么我会将它添加到末尾(用分号分隔)。
    猜你喜欢
    • 2013-12-16
    • 1970-01-01
    • 2014-01-23
    • 1970-01-01
    • 2011-03-15
    • 1970-01-01
    • 2014-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多