Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Error on application startup - could not load file or assembly

Tags:

c#

some users (i would say it is ~10%) exeperiences a problem while trying to run my application written in C# (.NET 4.0) - at application startup such error occures:

Could not load file or assembly 'lua51.dll'. Such module could not be found.

- It is translation, so in ENG version it could be similar.

The problem is that most of users don't experience this problem, and lua51.dll is present in program's directory. What could be the reason of this error?

I have set Platform: x86 in my project->bulid options, error occurs.

like image 412
user1792042 Avatar asked May 19 '13 13:05

user1792042


1 Answers

This is a common problem, too many programmers just copy the DLL without realizing that lua51.dll has itself dependent DLLs that need to be installed as well. The error message from Windows is sadly unhelpful, it doesn't report the true cause of the problem. An event in the Applciation log does, but not enough users look at it.

Unfortunately this doesn't go wrong often enough, lots of machines already have the dependent DLLs available. This is however an accident, you cannot rely on it. Those odds get lower and lower as well, the dependency is getting old.

You'll need to read the Install Notes to know what is required:

Lua for Windows and it's modules all depend on the MSVC++ 2005 runtime library. Lua for Windows install will automatically download this runtime and install it for you if you don't have runtime installed on your computer. The runtime is contained in the file vcredist_x86.exe

So either rely on the Lua installer or get the vcredist installed yourself.

like image 64
Hans Passant Avatar answered Oct 09 '22 05:10

Hans Passant