lua-users home
lua-l archive

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

Hi Mathijs,

Add an empty definition of lua_State to your app:

struct lua_State {};

The only definition of lua_State is in unmanaged code (the Lua C code), so the CLR can't find it and throws that exception. In fact, if you open your managed assembly with ildasm you won't find any reference to the Lua DLL at all. They are inside the unmanaged code of the stubs the compiler creates (you'll see lua_open, lua_close etc. in your managed assembly, those are the stubs that load the Lua DLL).

Fabio Mascarenhas

mathijs wrote:

I'm having a problem using lua and .net. I'm using an unmanaged class with lua in it in a managed .net app. It compiles fine but when calling the first function that uses lua I get the following error:

An unhandled exception of type 'System.TypeLoadException' occurred in Medusa Editor.exe

Additional information: Could not load type lua_State from assembly Medusa Editor, Version=1.0.1728.36664, Culture=neutral, PublicKeyToken=null.

The same class works fine in a fully unmanaged class.

Anyone had this problem before and/or knows how to fix it?

Thanks in advance,

Mathijs Baaijens.