我的 .NET 可执行文件abc.exe
引用了几个程序集。其中之一被称为xyz.core.exe
。当它从通过共享名称指定的网络位置启动时,我无法让它工作,例如\\localhost\xyz\abc.exe
. 如果我挂载一个名为Z:
on的网络驱动器号\\localhost\xyz
并且启动Z:\abc.exe
.
xyz.core.exe
.NET 在尝试从共享加载程序集时似乎变得困惑。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 程序集的引用产生相同类型的加载错误。
关于这个加载问题可能是什么原因的任何想法?有没有其他人遇到过这种情况?