SWI-Prolog / contrib-swiplcs

Interface from C# to SWI-Prolog
http://www.lesta.de/Prolog/SwiPlCs/Generated/Index.html
24 stars 10 forks source link

An unhandled exception error #4

Open kzcom opened 8 years ago

kzcom commented 8 years ago

Hi, I need to use C# interface to SWI-Prolog. I add the SwiPlCs.dll to project references and set SWI_HOME_DIR environment variable but when I tried to run first c# example from documentation i get the following error in ''PlEngine.Initialize(param)": " An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll Additional information: The specified module could not be found. (Exception from HRESULT: 0x8007007E) "

I created Console application and run it without debugging, it is shown this message in console: " SWI-Prolog:[FATAL ERROR: Could not find system resources] Press any key to continue... "

I set the SWI_HOME_DIR environment variable as follows: Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Program Files (x86)\swipl\bin"); and Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Program Files (x86)\swipl");

Additional information: OS win7-64bit , SWI-Prolog (Multi-threaded, 32 bits, Version 7.3.8),VS2013-32bit, dotNet4.5 , SwiPlCs_1.1.60605

How to I can fix this error? thanks.

alirehman commented 6 years ago

did you find the answer

NIKENIT commented 6 years ago

Still looking for the answer. Looks like the lib is completely broken. Win 10 x64, tried swi-prolog 7.3.8, 6.6.5, 6.6.4 both x32 and x64.

EDIT: Managed to fix it somehow by building my project directly into the \swipl\bin folder, and not mentioning the PATH variable. Huh.

EDIT2: Setting /bin/ folder as working catalogue for the debug fixes the issue too. Also, if you do that AND use link to /bin/ folder in your SWI_HOME_DIR, it says that it cannot find resource, but if you do that + link to /swipl/ folder in your SWI_HOME_DIR, everything works. Looks like SWI_HOME_DIR should acctualy work, but something changed either in windows variable management, or visual studio, and it now works not 100% of the time.

chaojian-zhang commented 1 year ago

With Net 7 and tried both x86 and x64 swipl no luck😂

chaojian-zhang commented 1 year ago

With Net 7 and tried both x86 and x64 swipl no luck😂

Current solution involves build from source and enable _PL_X64 on build. Will update to https://github.com/chaojian-zhang/contrib-swiplcs