Search code examples
dllconsole-applicationnlua

Unable to load DLL 'lua52': The specified module could not be found


I have the same problem as described here:

https://github.com/NLua/NLua/issues/33

Though I have followed the instructions to create a console application...

http://www.screencast.com/t/M12TqePQxW

...which works just fine, when I create a library project and reference it from another project (in this case, a Web API project) the following error occurs:

Unable to load DLL 'lua52': The specified module could not be found.

At this line:

using (var lua = new Lua())

How can a library project be made with the NLua nuget package without failing?


Solution

  • It is the exact same issue as described in the GitHub issue, the Nuget package is missing two DLLs that you need to use lua52.dll. One small difference, the current package (version 1.3.2.1) includes a newer version of lua52.dll that was built with VS2013. And therefore has a dependency on msvcr120.dll and msvp120.dll.

    Beware that this may change in the future when Nuget updates your project.

    As-is, you need to download and install the Visual C++ redistributable package for VS2013. Run both vcredist_x64.exe and vcredist_x86.exe so your project can run either in 32-bit or 64-bit mode.

    To avoid having to do this on the machine on which you want to deploy your program, I recommend you copy the two DLLs from the c:\windows\system32 (64-bit) or c:\windows\syswow64 (32-bit) directories into the same directory as your EXE.

    The package author could have done a better job putting this package together. Short from including the DLLs in the package, the better solution would be for him to rebuild lua52.dll with the /MT option so these dependencies are linked in. Consider clicking the New Issue button to let him know.