无法加载文件或程序集“***.dll”或其依赖项之一
我有一个很久以前创建的 dll,用于连接到我开发的特定软件的数据库。四年多来,我在使用这个 dll 的过程中和无数的应用程序中都没有遇到任何问题。
尝试部署我的最新创建时,我收到以下错误:
System.IO.FileNotFoundException: Could not load file or assembly '***.dll' or one of its dependencies. The specified module could not be found.
因此,对于我编写的每个 dll,我总是制作一个简单的表单应用程序来单独测试该 dll。运行那个简单的应用程序会产生相同的错误。该 dll 不会加载或使用除 System、System.Data、System.XML 以外的任何内容。就其依赖性而言,我不认为有什么问题。
顺便说一句,一切都在开发站上进行。该问题仅限于部署站。由于我用 C++ 做所有事情,.Net 和必要的可再发行组件已部署并运行。
运行 FUSLOGVW.exe 显示一切正常。
运行depends.exe时说:警告:由于延迟加载依赖模块中缺少导出功能,至少有一个模块存在未解析的导入。
我已经尝试重写整个事情。这产生了相同的结果。
有人提供线索吗?
编辑
以下是全部错误消息:
See the end of this message for details on invoking \"
just-in-time (JIT) debugging instead of this dialog box.\"
************** Exception Text **************\"
System.IO.FileNotFoundException: Could not load file or assembly 'connectionTo.dll' or one of its dependencies. The specified module could not be found.\"
File name: 'connectionToJobboss32.dll'\"
at TESTConnection.Form1.button1_Click(Object sender, EventArgs e)\"
at System.Windows.Forms.Control.OnClick(EventArgs e)\"
at System.Windows.Forms.Button.OnClick(EventArgs e)\"
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\"
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\"
at System.Windows.Forms.Control.WndProc(Message& m)\"
at System.Windows.Forms.ButtonBase.WndProc(Message& m)\"
at System.Windows.Forms.Button.WndProc(Message& m)\"
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\"
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\"
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\"
\"
************** Loaded Assemblies **************\"
mscorlib\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)\"
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll\"
----------------------------------------\"
TESTConnection\"
Assembly Version: 1.0.3996.18980\"
Win32 Version: \"
CodeBase: file:///C:/Program%20Files%20(x86)/conn/TESTConnection.exe\"
----------------------------------------\"
System.Windows.Forms\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 built by: RTMRel\"
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll\"
----------------------------------------\"
System.Drawing\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 built by: RTMRel\"
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll\"
----------------------------------------\"
System\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 built by: RTMRel\"
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll\"
----------------------------------------\"
事件查看器中没有错误。
I have this dll that I created a long time ago and use to connect to the db of a specific software that I develop for. I have had no issues for well over 4 years and countless applications with this dll.
Trying to deploy my latest creation, I get the following error:
System.IO.FileNotFoundException: Could not load file or assembly '***.dll' or one of its dependencies. The specified module could not be found.
So, for every dll I ever wrote, I always made a simple forms application to test that dll just by itself. Running that simple app yielded the same error. The dll doesn't load or use anything else than: System, System.Data, System.XML. So as far as depencies of it go, I don't see anything wrong.
By the way everything works on a dev station. The problem is limited to deployment stations. .Net and the necessary redistributables, since I do everything in C++, are deployed and working.
Running FUSLOGVW.exe showed everything as working fine.
Running depends.exe said: Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
I already tried rewriting the whole thing. Which yielded the same results.
Clues anyone?
EDITS
Here is the total error message:
See the end of this message for details on invoking \"
just-in-time (JIT) debugging instead of this dialog box.\"
************** Exception Text **************\"
System.IO.FileNotFoundException: Could not load file or assembly 'connectionTo.dll' or one of its dependencies. The specified module could not be found.\"
File name: 'connectionToJobboss32.dll'\"
at TESTConnection.Form1.button1_Click(Object sender, EventArgs e)\"
at System.Windows.Forms.Control.OnClick(EventArgs e)\"
at System.Windows.Forms.Button.OnClick(EventArgs e)\"
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\"
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\"
at System.Windows.Forms.Control.WndProc(Message& m)\"
at System.Windows.Forms.ButtonBase.WndProc(Message& m)\"
at System.Windows.Forms.Button.WndProc(Message& m)\"
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\"
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\"
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\"
\"
************** Loaded Assemblies **************\"
mscorlib\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)\"
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll\"
----------------------------------------\"
TESTConnection\"
Assembly Version: 1.0.3996.18980\"
Win32 Version: \"
CodeBase: file:///C:/Program%20Files%20(x86)/conn/TESTConnection.exe\"
----------------------------------------\"
System.Windows.Forms\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 built by: RTMRel\"
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll\"
----------------------------------------\"
System.Drawing\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 built by: RTMRel\"
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll\"
----------------------------------------\"
System\"
Assembly Version: 4.0.0.0\"
Win32 Version: 4.0.30319.1 built by: RTMRel\"
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll\"
----------------------------------------\"
There is no errors in the event viewer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
这是常见的问题,您无法使用 Fuslogvw.exe 看到丢失的非托管 DLL。最好的办法是运行 SysInternals 的 ProcMon 实用程序。您会看到它搜索 DLL,但没有找到。 Dependency Walker 中的配置文件模式也可以显示它。
That's the usual problem, you cannot see a missing unmanaged DLL with Fuslogvw.exe. Best thing to do is to run SysInternals' ProcMon utility. You'll see it searching for the DLL and not find it. Profile mode in Dependency Walker can show it too.
昨天我在 dll 上遇到了同样的问题,它引用的只是 System、System.Data 和 System.Xml。事实证明,平台类型的构建配置没有对齐。该 dll 是为 x86 构建的,使用它的程序是“任何 CPU”,由于我运行的是 x64 机器,因此它以 x64 方式运行该程序,并且 x86 dll 存在问题。我不知道这是否是你的问题,只是想我会提到它作为其他要检查的事情。
I had the same issue with a dll yesterday and all it referenced was System, System.Data, and System.Xml. Turns out the build configuration for the Platform type didn't line up. The dll was build for x86 and the program using it was "Any CPU" and since I am running a x64 machine, it ran the program as x64 and had issues with the x86 dll. I don't know if this is your issue or not, just thought that I would mention it as something else to check.
我最近遇到了这个问题,该应用程序可以在开发人员计算机上正常运行并选择其他计算机,但不能在最近安装的计算机上运行。事实证明,它运行的机器安装了 Visual C++ 11 Runtime,而新安装的机器则没有。 将 Visual C++ 11 运行时可再发行组件添加到应用安装程序修复了该问题...
I recently hit this issue, the app would run fine on the developer machines and select others machines but not on recently installed machines. It turned out that the machines it did work on had the Visual C++ 11 Runtime installed while the freshly installed machines didn't. Adding the Visual C++ 11 Runtime redistributable to the app installer fixed the issue...
我也有同样的问题。对我来说,这是由我的计算机上本地 IIS 服务器的默认设置引起的。因此,修复此问题的简单方法是使用内置的 Visual Studio 开发服务器:)
x64 计算机上较新的 IIS 版本有一个设置,默认情况下不允许运行 32 位应用程序。要在本地IIS中启用32位应用程序,请在IIS管理器中选择相关应用程序池,单击“高级设置”,然后将“启用32位应用程序”从False更改为True
I had the same problem. For me, it was caused by the default settings in the local IIS server on my machine. So the easy way to fix it, was to use the built in Visual Studio development server instead :)
Newer IIS versions on x64 machines have a setting that doesn't allow 32 bit applications to run by default. To enable 32 bit applications in the local IIS, select the relevant application pool in IIS manager, click "Advanced settings", and change "Enable 32-Bit Applications" from False to True
我最近遇到了这个。事实证明,旧的 DLL 是用以前的版本 (Visual Studio 2008) 编译的,并且引用了该版本的动态运行时库。我试图在只有 .NET 4.0 的系统上运行它,而且我从未安装过任何动态运行时库。解决方案是什么?我重新编译了 DLL 以链接静态运行时库。
在事件查看器 (EVENTVWR.EXE) 中检查应用程序错误日志。它将为您提供有关错误的更多信息,并可能指出问题的真正原因。
I ran into this recently. It turned out that the old DLL was compiled with a previous version (Visual Studio 2008) and was referencing that version of the dynamic runtime libraries. I was trying to run it on a system that only had .NET 4.0 on it and I'd never installed any dynamic runtime libraries. The solution? I recompiled the DLL to link the static runtime libraries.
Check your application error log in Event Viewer (EVENTVWR.EXE). It will give you more information on the error and will probably point you at the real cause of the problem.
这个答案与OP的情况完全无关,对于其他人来说也是一种非常不可能的情况,但以防万一它可以帮助某人......
在我的情况下,我得到“无法加载文件或程序集'System.Windows. Forms,Version=4.0.0.0 ...”,因为我使用 .Net Framework / SDK 版本 2 中的 ILDAsm.exe 和 ILAsm.exe 反汇编并重新组装了程序。从 .Net Framework / 切换到 ILDAsm.exe 和 ILAsm.exe SDK 版本 4 修复了该问题。
(奇怪的是,尽管我所做的事情可能看起来像是一个明显的错误,但是当使用 JetBrains dotPeek 检查时,生成的不起作用的 EXE 文件确实表明它的目标是 .Net 4。)
This answer is totally unrelated to the OP's situation, and is a very unlikely scenario for anyone else too, but just in case it may help someone ...
In my case I was getting "Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0 ..." because I had disassembled and reassembled the program using ILDAsm.exe and ILAsm.exe from .Net Framework / SDK version 2. Switching to ILDAsm.exe and ILAsm.exe from .Net Framework / SDK version 4 fixed the problem.
(Strangely, even though doing what I did may seem like an obvious error, the resulting EXE file that didn't work did indicate that it targeted .Net 4 when examined with JetBrains dotPeek.)
确定本机 DLL 具有哪些依赖项的更简单方法是使用 Dependency Walker - http://www.dependencywalker.com/< /a>
我分析了本机 DLL,发现它依赖于 MSVCR120.DLL 和 MSVCP120.DLL,这两个文件都没有安装在我的临时服务器上的 System32 目录中。我在临时服务器上安装了 C++ 运行时,问题得到了解决。
An easier way to determine what dependencies a native DLL has is to use Dependency Walker - http://www.dependencywalker.com/
I analysed the native DLL and discovered that it depended on MSVCR120.DLL and MSVCP120.DLL, both of which were not installed on my staging server in the System32 directory. I installed the C++ runtime on my staging server and the issue was resolved.
我遇到了同样的问题 - .dll 一直在工作,然后我的计算机崩溃了,之后我遇到了“无法加载文件或程序集 ....dll”的问题
两种可能的解决方案:当计算机崩溃时,可能会出现一些问题 删除该文件夹中的文件不一致
,重新编译,错误就消失了。
有一次我还必须删除我的包文件夹(我在其他地方读过)。允许 Visual Studio / nuget 安装缺少的软件包(或手动重新安装),然后一切又恢复正常。
I had the same issue - a .dll working all the time, then my computer crashed and afterwards I had this problem of 'could not load file or assembly ....dll'
Two possible solutions: when the computer crashed there may be some inconsistent files in
Deleting that folder, recompiling and the error was gone.
Once I had also to delete my packages folder (I had read that somewhere else). Allow Visual Studio / nuget to install missing packages (or manually reinstall) and afterwards everything was fine again.
遇到了同样的问题,并通过确保解决方案中的项目具有相同的配置和平台(在我的例子中是 Debug x64)来解决它。不知何故,VIsual Studio 的部分项目缺少 x64,我手动编辑了 .sln 文件(将配置和平台从正确构建的项目复制到缺少我所需设置的项目)。其中一个项目的情况如下:
但是,依赖项中有 Java 文件 (*.jar) 的项目又发生了同样的错误。我必须手动编辑环境变量才能创建具有该值的记录
为 Java 的路径,并将其放在 Path 项的顶部。
这解决了这个问题,直到我更新了我的机器上的 Java。我必须编辑环境变量中的版本号以匹配更新的文件夹名称。
Had the same issue and got it resolved by making sure projects in the solution have the same configuration and platform (in my case it was Debug x64). Somehow the VIsual Studio was missing x64 for part of the projects and I edited the .sln file manually (copied the configurations and platforms from correctly built projects to the projects that were missing the settings I needed). This is what it looks like for one of the projects:
But then the same error occurred for a project that had a Java file (*.jar) in the dependencies. I had to edit Environment Variables manually to create a record with this value
for Java's path, and put it on top of the Path items.
This fixed the issue until I updated Java on my machine. I had to edit the version number in Environment Variables to match the updated folder name.
1) 将 DLL 从“Externals\ffmpeg\bin”复制到项目的输出目录(可执行文件所在的位置);
2) 确保您的项目是为 x86 目标构建的(在 32 位模式下运行)。
关注此帖子了解更多信息
1) Copy DLLs from "Externals\ffmpeg\bin" to your project's output directory (where executable stays);
2) Make sure your project is built for x86 target (runs in 32-bit mode).
Follow this thread for more