有没有人知道什么会导致Fusion加载器简单地跳过DLL而没有任何警告或确认?

当我尝试从命令行应用程序中执行此操作时(在C#中)

Assembly.LoadFrom("c:\\Deploy\\bin\\WebServices.dll")

我明白这一点:

  

<!>“无法加载一个或多个请求的类型。检索LoaderExceptions属性以获取更多信息。<!> quot;

该DLL依赖于Platform.DLL,但该依赖项的加载失败,因此这行代码会引发异常。当我检查Fusion程序集加载消息时,这就是我所看到的:

=== Pre-bind state information ===
LOG: DisplayName = Platform, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null (Fully-specified)

...

LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\config\\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Project/bin/Debug/Platform.DLL.
LOG: Attempting download of new URL file:///C:/Project/bin/Debug/Platform/Platform.DLL.
LOG: Attempting download of new URL file:///C:/Project/bin/Debug/Platform.EXE.
LOG: Attempting download of new URL file:///C:/Project/bin/Debug/Platform/Platform.EXE.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform.DLL.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform/Platform.DLL.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform.EXE.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform/Platform.EXE.

问题是,DLL 出现在c:\Deploy\bin\Platform.DLL,具有正确的版本且没有签名的公钥。

我想到的事情:
也许它真的是Platform.DLL的依赖,它已经破坏了,导致了这种行为? (我在Reflector中追踪了依赖树,但发现没有丢失的DLL)
2.可能是发布/调试不匹配,或64位与32位?但一切都建立在同一台机器上 3.也许我误读了日志,但是当它遇到它发现的DLL时它不应该停止吗?我没有看到<!>“成功的<!>”;或者<!>“不成功的<!>”;此日志中的消息。我知道它因为例外而失败了。

PS更多技术细节:
机器环境是Windows 2008 64位,带有.NET 2.0,3.0 <!>放大器; 3.5安装。
这个应用程序在另一台机器(Vista 32位)上运行得很好,具有相同的目录结构和DLL,尽管这些是在该机器上构建的

有帮助吗?

解决方案

是的,它应该在找到所需的dll时停止,所以第五个<!>“;试图下载... <!>”;应该找到它......

但是从哪个命令行应用程序运行?如果它是Debug文件夹,那么您可以尝试的一些事情是

  1. 将相关dll放在同一个文件夹中
  2. 使用以下格式的.config文件对程序集和引用进行签名

    <dependentAssembly>
        <assemblyIdentity name="WebServices.dll" publicKeyToken="<whatever this public key it>" />
        <codeBase version="1.0.0.0" href="..\WebServices.dll" />
    </dependentAssembly>
    
  3. 签名,然后将依赖程序集放入GAC。

  4. 我可能会离开,但这是一些尝试。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top