[英].NET executable won't load referenced assemblies when started from \\localhost\xyz
My .NET executable abc.exe
references several assemblies. 我的.NET可执行文件
abc.exe
引用了几个程序集。 One of them is called xyz.core.exe
. 其中一个叫做
xyz.core.exe
。 I have trouble getting it to work when it is being started from a network location specified through a share name with a path such as \\\\localhost\\xyz\\abc.exe
. 当从通过共享名称指定的网络位置启动它时,我无法使其工作,例如
\\\\localhost\\xyz\\abc.exe
。 This works fine if I mount a network drive letter named Z:
on \\\\localhost\\xyz
and if I launch Z:\\abc.exe
. 如果我在
\\\\localhost\\xyz
上安装名为Z:
的网络驱动器号并且如果我启动Z:\\abc.exe
,则此方法可以正常工作。
.NET seems to become confused while trying to load the xyz.core.exe
assembly from the share. 尝试从共享加载
xyz.core.exe
程序集时,.NET似乎变得困惑。 It throws a System.IO.FileNotFoundException
exception with the following fusion log information: 它使用以下融合日志信息抛出
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.
Looking at this through another angle with Process Monitor, I see a few attempts to access on my local drive with the following paths: 通过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
as if the loader mis-understood the intent of loading from a network share and dropped the \\\\localhost
to use C:
instead. 好像加载器误解了从网络共享加载的意图并删除了
\\\\localhost
以使用C:
而不是。 The problem seems not to be related to security settings (I have never messed with CASPOL on my machine) and I am using .NET 3.5 SP1 which allows executables to be started from a share. 问题似乎与安全设置无关(我从未在我的机器上与CASPOL混淆)而且我使用的是.NET 3.5 SP1,它允许从共享中启动可执行文件。
And the fact that starting the program through the equivalent mapped network drive letter works should confirm that this is not a security issue. 通过等效的映射网络驱动器函数启动程序的事实应该确认这不是安全问题。
The problem is not related to the fact that the reference is to an EXE assembly either, as it produces the same kind of load errors with references to plain DLL assemblies. 该问题与引用也是EXE程序集的事实无关,因为它通过对普通DLL程序集的引用产生相同类型的加载错误。
Any ideas of what could be the cause of this loading problem? 有什么可能导致这个装载问题的想法? Has anybody else run into such a situation?
还有其他人遇到过这样的情况吗?
I can't explain the "C:\\xyz\\xyz.core.dll" (except as a curiosity), but the rest is exactly what I would expect. 我无法解释“C:\\ xyz \\ xyz.core.dll”(除了作为好奇心),但其余的正是我所期待的。
This seems all tied into code-access security. 这似乎都与代码访问安全性有关。 Until recently, you would need to use "caspol" to configure CAS to allow you to execute the exe from any type of network share.
直到最近,您还需要使用“caspol”来配置CAS,以允许您从任何类型的网络共享执行 exe。 This was changed (either .NET 3.5 or .NET 3.5 SP1) such that mapped shares ("f:" etc) do get execute permission, but UNC shares do not.
这被改变(无论是.NET 3.5或.NET 3.5 SP1),使得映射股份(“F:”等) 都得到执行权限,但UNC共享没有。
You can use "caspol" to grant access to the UNC ( like this ), but IMO it is a far better option to switch to ClickOnce deployment. 您可以使用“caspol”授予对UNC的访问权限( 如此 ),但IMO是切换到ClickOnce部署的更好选择。 This can still be via a network share, but it includes additional publication information that lets the runtime mount it.
这仍然可以通过网络共享,但它包含允许运行时安装它的其他发布信息。 I believe it can also be used to deploy such that it works offline (when the network is unavailable) but update automatically from the share when possible I know this works for http deployment - I believe it works for network).
我相信它也可以用于部署,使其脱机工作(当网络不可用时),但在可能的情况下自动从共享更新我知道这适用于http部署 - 我相信它适用于网络)。 The IDE presents this under the guise of "publish", and it is about 5 clicks all done.
IDE以“发布”为幌子呈现这一点,并且完成了大约5次点击。
I am confused - if you use localhost it is supposed to go to the local harddrive. 我很困惑 - 如果你使用localhost它应该去本地硬盘。
Are you trying to remap the localhost to point elsewhere? 您是否尝试将localhost重新映射到其他位置? If this is the case this can be what causes problems - try to use a different name
如果是这种情况,这可能是导致问题的原因 - 尝试使用不同的名称
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.