views:

416

answers:

2

When I try to use LuaInterface on Mono on Linux (using Mono 2.0 on Ubuntu 9.04) I get the following exception:

** (ParallelTasksSimulator.UI.exe:8599): WARNING **: Method ':.DoDllLanguageSupportValidation ()' in assembly 
'/home/ulrich/test/Debug/lua51.dll' contains native code that cannot 
be executed by Mono on this platform. 
The assembly was probably created using C++/CLI.

According to this web site LuaInterface can be used with Mono. MoMA says that too.

Is it possible to recompile lua51.dll to make it compatible to Mono?

+3  A: 

LuaInterface looks to be pure C#, but it uses a mixed mode C++/CLI-ified version of the Windows version of the native Lua library, that mixes .NEt code and native 32-bit Windows code. There's no C++/CLI compiler for platforms other than Windows, so you can't port/recompile the C++/CLI code, though it should work on Mono on Win32 (or maybe Wine)..

The only really viable way to get this to work on Mono would be to make it use P/Invokes istead of C++/CLI. You could then use a dllmap so that when Mono tries to resolve the P/Invoke calls to lua51.dll, it is redirected to the Linux equivalent, liblua.so.5.1.

mhutch
The problem is that lua51.dll doesn't use DLLImport(), but compiles the unmanaged Lua code directly into this managed library.
ulrichb
Oops, should have looked at LuaInterface mode carefully. Edited to make it correct.
mhutch
This doesn't sound good, because the http://luainterface.googlecode.com/svn/trunk/lua-5.1.2/lua511/LuaDLL.cpp seems to do a lot of "magic", ... And, .... WHY is there no mixed C++/CLI compiler???
ulrichb
A C++ compiler is very hard to create, let alone one like Microsoft's that can compile special syntax to a mixture of native code and IL with all the interop bits. As you say, there's a lot of magic involved.
mhutch
thanks for your answer!
ulrichb
+3  A: 

Older versions of LuaInterface use a pure P/Invoke wrapper. You could use this.

There are also a few attempts at alternatives, my own included. http://github.com/blankthemuffin/LuaSharp

jsimmons