Unexpected data object type error from Environment.Eval usage?

May 8, 2014 at 4:58 PM
Edited May 8, 2014 at 5:05 PM
Hi. I do this in my C# code:



Mommosoft.ExpertSystem.Environment clipsEngine = new Mommosoft.ExpertSystem.Environment();
//doing some stuff like loading templates\facts\rules
clipsEngine.Run(); //I beleive it shouldn't proceed untill rules are completed?
clipsEngine.Eval("(do-for-all-facts ((?f pricefact)) TRUE (retract ?f))");

And when Eval is called I get this:

System.ArgumentException was unhandled
HResult=-2147024809
Message=Unexpected data object type.
Parameter name: dataObject
Source=Mommosoft.ExpertSystem
ParamName=dataObject
StackTrace:
   at Mommosoft.ExpertSystem.Environment.ConvertDataObject(DATA_OBJECT dataObject)
   at Mommosoft.ExpertSystem.Environment.Eval(String expressionString)
   at FactEventAnalyzer.ClipsRulesRunner.runClipsRules(Parameters CurParam) in d:\Programs\FactEventAnalyzer\FactEventAnalyzer\FactEventAnalyzer\ClipsRulesRunner.cs:line 38
   at FactEventAnalyzer.Program.Main() in d:\Programs\FactEventAnalyzer\FactEventAnalyzer\FactEventAnalyzer\Program.cs:line 45
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:

What's wrong? I tried running this directly in ClipsWin UI and it works perfectly.

UPDATE: it actually DOES the job, I added this peace after first Eval and proceeded after that error happened:
clipsEngine.Eval("(save-facts)");

And as I see in resulting file even though the error which I have mentioned happens it still really retracts the facts I specified in first Eval. What's wrong with it, how I could avoid the error mentioned?
May 12, 2014 at 1:41 PM
Anyone?

I wrapped this code in Try\Catch to make my app run, but it is defenetly noot a good way of solving this.
Dec 25, 2014 at 5:38 AM
Hi there
I do appreciate your help end the problem was.
I can whole-language: c# to Clips Send a command value
:::::::::: enviroment.AssertString("(attribute (name preferred-color) (value red))");

But I can not get the value of a property after running expert system
text.text= (((( name ))))??????????????????????