我正在尝试将 LuaInterface 集成到 C# 中,System.NullReferenceException
当我尝试将 C# 函数绑定到 Lua 时,我得到了一个。我试图编译和运行的代码是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LuaInterface;
namespace Hobot
{
class Program
{
static void Main(string[] args)
{
Program program = new Program();
Lua lua = new Lua();
lua.RegisterFunction("puts", null, typeof(Program).GetMethod("Test"));
lua.DoFile("test.lua");
}
private void Test(String text)
{
Console.WriteLine(text);
}
}
}
当我运行这段代码时,我会System.NullReferenceException
说它Additional information: Object reference not set to an instance of an object.
在RegisterFunction
方法上崩溃了。