Fusion loader找不到实际存在的DLL

问题描述 投票:3回答:1

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

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

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

我看到了这个:

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

该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,尽管这些是在该机器上构建的

c# .net assemblies fusion
1个回答
1
投票

是的,它应该在找到所需的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中。

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

© www.soinside.com 2019 - 2024. All rights reserved.