lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm trying to use LuaInterface to do some scripting of the .Net CLR.  When I try to make a Lua table a subclass of a CLR object with the luanet:make_object function, Lua crashes.  Do you have any idea what I'm doing wrong? 

This is the error message:

Unhandled Exception: System.AccessViolationException: Attempted to read or write
 protected memory. This is often an indication that other memory is corrupt.
   at LuaInterface.LuaDLL.lua_safetostring (IntPtr luaState, Int32 index, StringBuilder buffer)
   at LuaInterface.ObjectTranslator.registerTable(IntPtr luaState)

Below is the code I'm trying to run when it crashes:

require("compat-5.1")
require("luanet")


luanet.load_assembly("Microsoft.Xna.Framework")
luanet.load_assembly("Microsoft.Xna.Framework.Game")

MsFramework=luanet.import_type("Microsoft")
MsGame=luanet.import_type('Microsoft.Xna.Framework.Game')

MyGame={}
function MyGame:InitializeComponent()
    self.graphics=Microsoft.Xna.FrameWork.Components.GraphicsComponent()
    self.GameComponents:Add (self.graphics)
end


function MyGame:Update()
    self.UpdateComponents()
end

function MyGame:Draw()
    if not self.graphics:EnsureDevice() then
        return
    end
    self.graphics.GraphicsDevice:Clear (Color.CornflowerBlue)
    self.graphics.GraphicsDevice:BeginScene()
    self.DrawComponents()
    self.graphics.GraphicsDevice:EndScene()
    self.graphics.GraphicsDevice:Present()
end

luanet:make_object(MyGame, MsGame)
MyGame:run()