C# – Integrating C# and Prolog

cprolog

For a project I'm working on I'd like to use WordNet to do some linguistic classification of user input, and I'd like to use the Prolog version of the database.

I've tried P#, which works reasonably well, but which appears to be unable to handle the sheer size of the WordNet databases. It can compile the smallest of the files I want to use (218 kB), but when I try to compile the two larger ones (2.3 and 7.3 MB, respectively) it fails after about half an hour of work and Windows pops up the "Something went wrong. Send report to Microsoft?" dialog.

I've also tried Prolog.Net, which just appears to not work very well.

Finally, I tried the C# bindings for SWI-Prolog, but can't get them to work properly. When I try to run the example code, it fails at the PLEngine.Initialise() step, claiming that something it tries to load (a DLL I assume) is an invalid Win32 application (a BadImageFormatException).

Does anyone have either any suggestions for other ways to integrate C# and Prolog, or some suggestions to get the solutions I've already tried to work? OS is Windows server 2008 (64 bit), SWI Prolog is version 5.7.11.

Best Answer

Perhaps you are having problems with 32 bit SWI-Prolog on 64 bit Windows. If your platform target is Any CPU it might be the cause of your problems. You can fix this by opening the properties pages for you C# project. Select the Build tab and change the Platform target to x86.

If you currently are using Any CPU your application will run in 64 bit on 64 bit Windows. Trying to load an 32 bit DLL will fail miserably.

Related Topic