我有这个:
public static List<int> caminhoMaisCurto(int iduser1, int iduser2)
{
List<int> ret = new List<int>();
using (PlQuery q = new PlQuery("mais_curto(" + iduser1 + "," + iduser2 + ",C)."))
{
PlTermV v = q.Solutions.First();
IReadOnlyCollection<PlTerm> lista = v[2].ToList();
foreach(var row in lista)
{
int num = Convert.ToInt32(row.ToString());
ret.Add(num);
}
}
return ret;
}
它属于与.pl文件与prolog通信的Web服务。
它是这样的:
public static void init()
{
Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Users\João\Desktop\SWI-PrologPortable\App\SWI-Prolog");
Environment.SetEnvironmentVariable("Path", @"C:\Users\João\Desktop\SWI-PrologPortable\App\SWI-Prolog");
Environment.SetEnvironmentVariable("Path", @"C:\Users\João\Desktop\SWI-PrologPortable\App\SWI-Prolog\\bin");
if (!PlEngine.IsInitialized)
{
String[] param = { "-q", "-s", "C:\\Users\\João\\final\\lapr5-dei-link\\DAL_BLL\\AIWebService\\AIWebService\\AI.pl" }; // suppressing informational and banner messages
PlEngine.Initialize(param);
}
}
并在此行中显示System.AccessviolationException
:
using (PlQuery q = new PlQuery("mais_curto(" + iduser1 + "," + iduser2 + ",C)."))
我不明白为什么......有人可以帮忙吗?