gpt4 book ai didi

c# - 为什么在 IIS CGI 程序中出现程序集绑定(bind)失败

转载 作者:行者123 更新时间:2023-11-30 21:22:29 26 4
gpt4 key购买 nike

我有一个 C# 程序在 XP Pro SP3 上的 IIS 中作为 CGI 应用程序运行。在我引用库程序集类并在程序代码中使用它之前,它运行良好。如果我手动运行 CGI 程序,它会加载并执行。但是当它由 IIS 运行时,引用的程序集无法绑定(bind),尽管它与父可执行文件位于同一目录中。这是我得到的绑定(bind)日志:

=== Pre-bind state information ===LOG: User = STEVIENEW\IUSR_STEVIENEWLOG: DisplayName = VOEvent, Version=3.0.7.0, Culture=neutral, PublicKeyToken=null (Fully-specified)LOG: Appbase = file://?/C:/Documents and Settings/Robert B. Denny/My Documents/iis/vomsgtst/LOG: Initial PrivatePath = NULLCalling assembly : MsgChkCGI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.===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: 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:/Documents and Settings/Robert B. Denny/My Documents/iis/vomsgtst/VOEvent.DLL.LOG: Attempting download of new URL file://?/C:/Documents and Settings/Robert B. Denny/My Documents/iis/vomsgtst/VOEvent/VOEvent.DLL.LOG: Attempting download of new URL file://?/C:/Documents and Settings/Robert B. Denny/My Documents/iis/vomsgtst/VOEvent.EXE.LOG: Attempting download of new URL file://?/C:/Documents and Settings/Robert B. Denny/My Documents/iis/vomsgtst/VOEvent/VOEvent.EXE.

Appbase 是正确的(虽然 URI 中的“?”是什么?????也许这是一个提示)。程序集 voevent.dll 肯定与 MsgChkCGI.exe 位于同一目录 (Appbase!) 中。如果我只是双击 exe,它会正确启动(并且由于缺少 CGI 环境变量而出现错误,但这是预料之中的)。

有人知道这是怎么回事吗?

最佳答案

我不确定为什么会发生这种情况。

作为解决方法,您可以处理 AppDomain.CurrentDomain.AssemblyResolve

编辑:请注意,如果您在添加处理程序的同一方法中使用来自另一个程序集的类型,则事件不会触发,因为程序集将在代码之前由 JITter 加载该方法实际执行。
因此,您需要将使用来自其他程序集的类型的任何代码放在一个单独的方法中,然后在处理 AssemblyResolve 之后调用该方法。

第 2 编辑:调用 Assembly.Load(File.ReadAllBytes(path))
此外,您能否编辑您的问题以包含 Assembly.LoadFileFileNotFoundException 的所有详细信息?

关于c# - 为什么在 IIS CGI 程序中出现程序集绑定(bind)失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2293852/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com