In a C# application, I want to use Aleph for constructing a theory.
The following works in SWI-Prolog:
?- [aleph.pl]. ?- working_directory(CDW,'C:/Users/admin/Desktop/inputFiles'). ?- read_all(datainput). ?- induce.
But in C# these commands don't:
if (!PlEngine.IsInitialized) { String[] param = { "-q" }; PlEngine.Initialize(param); PlQuery.PlCall("consult('C:/Users/admin/Desktop/Aleph_pack/Aleph.pl')"); PlQuery.PlCall("working_directory(CDW,'C:/Users/admin/Desktop/inputFiles')); PlQuery.PlCall("assert(read_all(datainput))"); // ERROR! PlQuery.PlCall("assert(induce)"); }
I get the following error for PlQuery.PlCall("assert(read_all(datainput))")
:
An unhandled exception of type 'SbsSW.SwiPlCs.Exceptions.PlException' occurred in SwiPlCs.dll Details: SbsSW.SwiPlCs.Exceptions.PlException was unhandled HResult=-2146233088 Message=assert/1: No permission to modify static procedure `read_all/1' Defined at c:/users/admin/desktop/aleph_pack/aleph.pl:8857
How can I fix this error?
The reason why you get the error with C#, but not when using Prolog directly, is this:
Let's interleave the above two snippets:
So you are using prolog-assert in the C# code, but not in the interactive SWI-Prolog session.
A part of the multi-line error you got, points in that direction, too:
Resume your investigation by pondering on that difference. If you have older versions of your code that exhibited different behaviour, examine them (and the delta to the current code), too!