I was wondering has anyone tried calling newlispEvalStr from a C# application? Do you have some code to show me how or can you point me in the right direction?
I have tried using dllImport and it seems (i.e. in debug view I can see (+ 2 2) returns "4\n") to work but I keep getting AccessViolationExceptions.
Class which import newlisp.dll (NewLispDLL.cs) is:
Code: Select all
using System;
using System.Text;
using Microsoft.CSharp;
using System.Runtime.InteropServices;
class NewLispDLL
{
[DllImport("C:\\Program Files\\newlisp\\newLisp.dll", EntryPoint = "newlispEvalStr", CallingConvention = CallingConvention.Cdecl)]
private static extern System.Text.StringBuilder newlispEvalStr(string txt);
public static string Eval(string LispExpression)
{
System.Text.StringBuilder ResultObject;
ResultObject = newlispEvalStr(LispExpression);
return ResultObject.ToString();
}
}
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
namespace NewLispTest
{
class Program
{
static void Main(string[] args)
{
string strCmd = "(+ 2 2)";
string txt = "";
txt = NewLispDLL.Eval(strCmd);
Console.WriteLine(txt);
Console.ReadLine();
}
}
}