Fusion 加载程序找不到实际存在的 DLL
有谁知道什么会导致 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 is 位于 c:\Deploy\bin\Platform.DLL
中,其中正确的版本并且没有签名的公钥。
我想到的事情:
1. 也许确实是 Platform.DLL 的依赖项已损坏,导致了此行为? (我在 Reflector 中追踪了依赖树,但没有发现丢失的 DLL)
2. 也许存在发布/调试不匹配,或者 64 位与 32 位不匹配的情况?但一切都是在同一台机器上构建的
3.也许我误读了日志,但是当它遇到它找到的DLL时,它不应该停止吗?我在此日志中没有看到“成功”或“不成功”消息。我只知道它因异常而失败。
PS更多技术细节:
机器环境为Windows 2008 64位,带有.NET 2.0、3.0 & . 3.5已安装。
这个相同的应用程序在另一台机器(Vista 32 位)上运行得很好,具有相同的目录结构和 DLL,尽管它们是在该机器上构建的
Does anyone have any idea what would cause the Fusion loader to simply skip over a DLL with no warning or acknowledgement?
When I attempt to do this (in C#) from a command-line application
Assembly.LoadFrom("c:\\Deploy\\bin\\WebServices.dll")
I see this:
"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."
That DLL has a dependency on Platform.DLL, but the loading of that dependency fails so this line of code throws an exception. When I check the Fusion assembly loading message, this is what I see:
=== 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.
The thing is, the DLL is present at c:\Deploy\bin\Platform.DLL
, with proper version and no signed public key.
Things I've thought of:
1. Maybe it's really a dependency of Platform.DLL that's broken, causing this behavior? (I chased the dependency tree in Reflector but found no missing DLLs)
2. Maybe there's a release/debug mismatch, or a 64-bit vs 32-bit? but everything was built on the same machine
3. Maybe I'm misreading the logs, but shouldn't it stop when it hits a DLL that it finds? I don't see either the "successful" OR the "unsuccessful" message in this log. I just know it failed because of the exception.
PS more tech details:
Machine environment is Windows 2008 64-bit, with .NET 2.0, 3.0 & 3.5 installed.
This same application runs just fine on another machine (Vista 32-bit), with the same directory structure and DLLs, although those were built on that machine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,当它找到所需的 dll 时,它应该停止,所以第五个“尝试下载...”应该找到它...
但是命令行应用程序从哪里运行?如果它是 Debug 文件夹,那么您可以尝试以下一些操作:
通过以下格式的 .config 文件对程序集进行签名并引用
对它们进行签名,然后将依赖程序集放入 GAC 中。
我可能还很遥远,但这是一些值得尝试的事情。
Yep it should stop when it finds the required dll so the fifth "Attempting to download..." should have found it...
However where is the command line app being run from? If it's the Debug folder then a few things you can try are
Sign the assembly and reference through a .config file in the following format
Sign them and then put the dependent assemblies in the GAC.
I might be way off but that's a few things to try.