无法加载文件或程序集"XXXX.dll"或其依赖项之一.指定的模块无法找到 [英] Could not load file or assembly 'XXXX.dll' or one of its dependencies. The specified module could not be found

查看:79
本文介绍了无法加载文件或程序集"XXXX.dll"或其依赖项之一.指定的模块无法找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个直接引用dll文件的应用程序: POSLink.dll .

为了使其在我的本地计算机上运行,​​我必须手动将以下dll复制到输出目录: libea32.dll ssleay32.dll .

当我在本地计算机上运行该应用程序时,它会成功.

在目标计算机上运行应用程序时,出现以下错误:

未处理的异常:System.IO.FileNotFoundException:无法加载文件或程序集POSLink.dll或其依赖项之一.找不到指定的模块.
在FileNotFoundExceptionExample.Program.Main(String [] args)

这是我的SSCCE

 使用POSLink;使用系统;命名空间FileNotFoundExceptionExample{班级计划{静态void Main(string [] args){//这是在POSLink命名空间中找到的东西var commSetting = new CommSetting();commSetting.saveFile();Console.WriteLine("Success");}}} 

我尝试在POSLink.dll上使用

事实证明,确实缺少了msvcr120.dll,找到了一个合适的文件,然后将其放入我的输出目录中,从而解决了该问题.

注意::

I have an application that directly references a dll file: POSLink.dll.

In order to get this to run on my local machine, I have to manually copy the following dlls to the output directory: libea32.dll and ssleay32.dll.

When I run the application on my local machine, it succeeds.

When I run the application on the target machine, I get the following error:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'POSLink.dll' or one of its dependencies. The specified module could not be found.
at FileNotFoundExceptionExample.Program.Main(String[] args)

This is my SSCCE

using POSLink;
using System;

namespace FileNotFoundExceptionExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // this is stuff found in the POSLink namespace
            var commSetting = new CommSetting();
            commSetting.saveFile();

            Console.WriteLine("Success");
        }
    }
}

I tried using Dependency Walker on POSLink.dll, but that wasn't very useful to me because there are 381 errors that show up, and they show up when I run it on the successful machine too.

How do I even begin troubleshooting this error?


When I run the Fuision log viewer and then run the application on the target machine, I get the following log:

* Assembly Binder Log Entry (7/19/2016 @ 2:18:48 PM) *

The operation was successful. Bind result: hr = 0x0. The operation
completed successfully.

Assembly manager loaded from:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under
executable
C:\Users\Omitted\Desktop\notfoundexceptionexample\debug \FileNotFoundExceptionExample.exe
--- A detailed error log follows.

=== Pre-bind state information === LOG: DisplayName = POSLink, Version=1.0.5773.36725, Culture=neutral,
PublicKeyToken=f3876d2e4b7eb819 (Fully-specified) LOG: Appbase =
file:///C:/Users/Omitted/Desktop/notfoundexceptionexample/debug/ LOG:
Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base =
NULL LOG: AppName = FileNotFoundExceptionExample.exe Calling assembly
: FileNotFoundExceptionExample, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null.
=== LOG: This bind starts in default load context. LOG: Using application configuration file:
C:\Users\Omitted\Desktop\notfoundexceptionexample\debug\FileNotFoundExceptionExample.exe.Config
LOG: Using host configuration file: LOG: Using machine configuration
file from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: POSLink, Version=1.0.5773.36725,
Culture=neutral, PublicKeyToken=f3876d2e4b7eb819 LOG: GAC Lookup was
unsuccessful. LOG: Attempting download of new URL
file:///C:/Users/Omitted/Desktop/notfoundexceptionexample/debug/POSLink.DLL.
LOG: Assembly download was successful. Attempting setup of file:
C:\Users\Omitted\Desktop\notfoundexceptionexample\debug\POSLink.dll
LOG: Entering run-from-source setup phase. LOG: Assembly Name is:
POSLink, Version=1.0.5773.36725, Culture=neutral,
PublicKeyToken=f3876d2e4b7eb819 LOG: Binding succeeds. Returns
assembly from
C:\Users\Omitted\Desktop\notfoundexceptionexample\debug\POSLink.dll.
LOG: Assembly is loaded in default load context.

解决方案

So, as it turns out, there is a way to filter through all the unimportant errors that dependency walker tells you about.

  1. obtain Dependency Walker.
  2. obtain a diff tool. I used WinMerge.
  3. Run Dependency walker on the dll in question on your good machine. Copy the contents of the log window to a text file and save it.
  4. Run Dependency walker on the dll in question on your bad machine. Copy the contents of the log window to a text file and save it.
  5. Use your diff tool to diff the two txt files. In my case, The missing dll was in the top section(where the errors are) on the bad machine, ind in the bottom section(where the non-errors are) on the good machine.

Frankly I'm embarrassed that I didn't try this before. I had only assumed that the number of errors was the same based on how I assumed the log was laid out.


The log is the middle window that's selected in this screenshot.

As it turns out msvcr120.dll was indeed what was missing, and finding a suitable one, and dropping it into my output directory fixed the problem.

NOTE: msvcr120.dll is the Visual C++ 2013 Runtime. Instead of manually copying dlls around, the proper solution is installing the Visual C++ Redistributable Packages for Visual Studio 2013

这篇关于无法加载文件或程序集"XXXX.dll"或其依赖项之一.指定的模块无法找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆