在 C# 4.0 上使用 LuaInterface 时,在 lua51.dll 上出现 FileNotFoundException,但它就在那里
我一直在几个需要脚本编写的 C# 应用程序中使用 LuaInterface 和 Lua 5.1,最引人注目的是一些游戏、一个 IRC 机器人和一个完整的 IRC 客户端,我最近决定继续开发它们。
有一次,我切换到.Net 4.0,并且不得不重新编译 LuaInterface 和 Lua51 只是为了让它们再次运行。据我所知,一切都很好。
然而,我最近买了一台新笔记本电脑并尝试用它运行我的机器人。令我惊讶的是,当它尝试初始化 Lua 时,它崩溃了,引用了 lua51.dll 上的 FileNotFoundException,而 lua51.dll 就在那里。我耸耸肩,稍后再继续重新安装,包括 Visual C# 和 C++ 2010 Express 以及一些更新。第二天早上,我尝试再次启动聊天机器人来尝试找出答案 - 你瞧,它成功了。由于某种奇怪的原因。
今天早些时候,我的一个朋友告诉我完成我正在开发的 IRC 客户端,该客户端相当广泛地使用 Lua 来添加功能和其他很酷的东西。我给了那位朋友一份副本来检查最重要的问题......他得到了完全相同的错误。
现在,另一个人没有 Visual Studio,我无法重现该问题,并且不能指望我上面列出的其他东西的用户安装它只是为了让它们运行 - 一般相对理智的用户只会耸耸肩并摆脱该程序。
那怎么办,所以?
I've been using LuaInterface and Lua 5.1 in several C# applications that required scripting, most notably a few games, an IRC bot and a full IRC client that I've recently decided to resume working on.
At one point, I switched to .Net 4.0 and had to recompile LuaInterface and Lua51 just to get them to run again. As far as I could tell, all was good.
However, I recently bought a new laptop and tried to run my bot from it. To my surprise it broke when it tried to initialize Lua, citing a FileNotFoundException on lua51.dll, which was sitting right there. I shrugged it off for later and continued reinstalling things, including Visual C# and C++ 2010 Express, and some updates. The next morning I tried starting the chatbot again to try and figure it out -- lo and behold, it worked. For some strange reason.
Earlier today, a friend of mine told me to finish the IRC client I was working on, which makes rather extensive use of Lua to add functions and other cool stuff. I gave said friend a copy to check out for the most important problems... and he got the exact same error.
Now, the other guy does not have Visual Studio, I can't reproduce the problem, and one can't expect users of the other things I listed above to install it just to get them running -- the average relatively sane user would just shrug and get rid of the program.
So what do, SO?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这使得它很可能抱怨找不到 lua51.dll 需要的 DLL。很可能的一个是 msvcr100.dll,C/C++ 运行时支持库。当您安装 Visual Studio 时,会安装它。您可以使用 /MT 选项重建 lua,以便 CRT 包含在 DLL 本身中。或者告诉您的朋友下载并安装此。
Which makes it likely that it complained about not finding a DLL that lua51.dll needs. A very likely one is msvcr100.dll, the C/C++ runtime support library. Which does get installed when you install Visual Studio. You can rebuild lua with the /MT option so the CRT is included in the DLL itself. Or tell your friend to download and install this.
您可以尝试 SysInternals 的进程监视器。我经常用它来找出此类问题的根本原因。它将向您显示应用程序在文件系统上的何处查找 dll 的低级详细信息,这应该可以告诉您为什么没有找到它。
您可能需要使用搜索和过滤选项,因为它会生成大量数据,但它是我发现的解决此类问题的最佳工具。
You can try SysInternals' Process Monitor. I often use this to figure out the root cause of these sorts of problems. It will show you low-level details of where on the file system the application is looking for the dll which should give you an indication of why it's not being found.
You will probably need to play with the search and filtering options because it generates a lot of data, but it's the best tool I've found for troubleshooting issues like this.