1

Using visual studio with class application I added the NLua via NuGet. I want to read in and .lua file (BTW, of there is a better way do let me know) My code is this:

...
using NLua;
...
using (Lua lua = new Lua())...

But when I run it I get an exception on the above line:

System.BadImageFormatException HResult=0x8007000B Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) Source=KeraLua StackTrace: at KeraLua.NativeMethods.luaL_newstate() at NLua.Lua..ctor()

What am I doing wrong? I tried to search the internet and came up with solutions that it is since I am running a 64bit app while the one I am trying to load (NLUA) in 32bit. Is that it?

THANK YOU

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
dandan
  • 509
  • 3
  • 8
  • 21
  • Are your ```lua.DoString...``` works correctly? if no is LuaDist had installed ( or somethings like that ) in your machine before?? – Ali Bigdeli Aug 01 '20 at 21:12
  • I cannot define a new Lua() object at all therefore I cant use lua.DoString. I did not install LusDist, as far as I know – dandan Aug 01 '20 at 21:14
  • what about LuaDist installation ( or other versions of lua in windows ) in your system? – Ali Bigdeli Aug 01 '20 at 21:16
  • I have a game DCS which is using LUA language. This is why I want to use lua. to read its files – dandan Aug 01 '20 at 21:23
  • how can i check if i have this and fix this? – dandan Aug 01 '20 at 21:31
  • Have you try to change ```Platform target ``` from ```x64``` to "Any Cpu" ? (if the answer is no you can find it in your project properties-> build section) – Ali Bigdeli Aug 01 '20 at 21:36
  • i have, it was set to "Any CPU", I tried both x86 and 64 with the same result and put it back to "Any CPU" – dandan Aug 02 '20 at 04:18
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/219078/discussion-between-dandan-and-ali-bigdeli). – dandan Aug 02 '20 at 04:19
  • What versions of `Nlua` and `KeraLua` are you using? – Nifim Aug 02 '20 at 04:58
  • I downloaded in via visual studio "Add Nuget" panel. It's the latest I believe. Nlua 1.5.0 KeraLue 1.2.4 – dandan Aug 02 '20 at 05:00
  • I tried on another PC, without the game code and I get the same error. I don't know if it is related but I try to use Lua from within a class library, being invoked from my test console app – dandan Aug 02 '20 at 08:31

0 Answers0