【发布时间】:2010-01-29 06:35:30
【问题描述】:
我的 .NET 可执行文件 abc.exe 引用了几个程序集。其中之一称为xyz.core.exe。当它从通过共享名指定的网络位置启动时,我无法让它工作,路径如\\localhost\xyz\abc.exe。如果我在\\localhost\xyz 上挂载一个名为Z: 的网络驱动器号,并且如果我启动Z:\abc.exe,这将正常工作。
.NET 在尝试从共享加载 xyz.core.exe 程序集时似乎变得混乱。它会抛出 System.IO.FileNotFoundException 异常,并带有以下融合日志信息:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable \\localhost\xyz\abc.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = Workstation\arnaud
LOG: DisplayName = xyz.core, Version=2.5.2.1001, Culture=neutral, PublicKeyToken=...
(Fully-specified)
LOG: Appbase = file://localhost/xyz/
LOG: Initial PrivatePath = NULL
Calling assembly : abc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: xyz.core, Version=2.5.2.1001, Culture=neutral, PublicKeyToken=...
LOG: Attempting download of new URL file://localhost/xyz/xyz.core.DLL.
LOG: Attempting download of new URL file://localhost/xyz/xyz.core/xyz.core.DLL.
LOG: Attempting download of new URL file://localhost/xyz/xyz.core.EXE.
LOG: Attempting download of new URL file://localhost/xyz/xyz.core/xyz.core.EXE.
使用 Process Monitor 从另一个角度来看,我看到一些尝试通过以下路径访问我的本地驱动器:
C:\xyz\xyz.core.dll
C:\xyz\xyz.core\xyz.core.dll
C:\xyz\xyz.core.exe
C:\xyz\xyz.core\xyz.core.exe
就好像加载器误解了从网络共享加载的意图并放弃了\\localhost 以使用C:。这个问题似乎与安全设置无关(我从来没有在我的机器上弄乱过 CASPOL),我使用的是 .NET 3.5 SP1,它允许从共享启动可执行文件。
通过等效的映射网络驱动器号启动程序这一事实应该证实这不是安全问题。
这个问题也与引用是一个 EXE 程序集这一事实无关,因为它与对普通 DLL 程序集的引用产生相同类型的加载错误。
您对导致此加载问题的原因有任何想法吗?有没有其他人遇到过这种情况?
【问题讨论】:
-
您的跟踪显示 \\localhost\xyz 共享映射到 c:\xyz。这听起来很合理。它实际映射到什么以及程序集在哪里?
标签: c# networking load assembly-resolution fusion