我正在尝试使用 Lua 编写脚本:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LuaInterface;
namespace Scripting {
public class LuaParser {
Lua lua;
string path;
public LuaParser(string path) {
this.path = path;
lua = new Lua();
}
public void ParseClass(string ClassName) {
string p = path + ClassName + ".lua";
lua.DoFile(p);
}
public Lua Parser {
get {
return lua;
}
}
}
}
-----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Scripting {
class Program {
static void Main(string[] args) {
LuaParser p = new LuaParser("C:\\Users\\Administrator\\Documents\\Visual Studio 2012\\Projects\\Scripting\\Scripting\\bin\\Debug\\");
p.ParseClass("test");
}
}
}
和 test.lua :-
luanet.loadassembly("Scripting");
但它不工作它抛出这个异常: -
LuaInterface.LuaException was unhandled
HResult=-2146232832
Message=...2012\Projects\Scripting\Scripting\bin\Debug\test.lua:1: No such type: loadassembly
Source=LuaInterface
StackTrace:
at LuaInterface.Lua.ThrowExceptionFromError(Int32 oldTop)
at LuaInterface.Lua.DoFile(String fileName)
at Scripting.LuaParser.ParseClass(String ClassName) in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\Scripting\Scripting\LuaParser.cs:line 20
at Scripting.Program.Main(String[] args) in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\Scripting\Scripting\Program.cs:line 11
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:
test.lua , lua51.dll 和 LuaInterface.dll 在同一目录下,这里缺少什么?