We are doing a project in .NET framework and want to make most of its functionalities available later for Lua scripts. I thought I could compile a dll and load it to Lua script with the help of LuaInterface. But somehow it did not work.
What DID work is the following:
require 'luanet'
luanet.load_assembly("System.Windows.Forms")
Form = luanet.import_type("System.Windows.Forms.Form")
Button = luanet.import_type("System.Windows.Forms.Button")
form1 = Form()
button1 = Button()
As you can see, here I'm loading standard assembly and types, which didn't cause much problem. However, if I have my own dll 'LuaTest' compiled under .NET 4.0 and try to load it in LUA. It did not work. I wrote something like,
require 'luanet'
luanet.load_assembly("LuaTest")
PlanetarySystem = luanet.import_type("LuaTest.PlanetarySystem")
solarSystem = PlanetarySystem()
where 'PlanetarySystem' is a class in LuaTest. If I run this piece of code, the interpreter would say: attempt to call global 'PlanetarySystem' (a nil value).
I also tried another way to load the dll:
package.path = package.path .. ";" .. "/?.dll"
require 'luanet'
require 'LuaTest'
After run, the interpreter throws: lua: error loading module 'LuaTest' from file '.\LuaTest.dll': The specified procedure could not be found.
I'm quite a newbie to .NET framework and LuaInterface. Perhaps I did something utterly wrong. Please help me on this. Many thanks!
Edit: Perhaps I should have an 'Entry Point' for Lua in my dll to indicate that this dll is LUA loadable???
Edit: Lua not LUA. No offense to Portuguese speaking people. The Lunanet I'm using must be compatible with .NET 4.0, otherwise the first piece of code would not work.