我正在处理旧版Web应用程序,并且遇到运行时程序集绑定错误(FileNotFoundException
)
我查看了应用程序的基本目录,并确认bin /目录下是否存在具有正确版本和公共令牌的必需DLL。
我使Fusion Log on Server能够捕获详细信息,并意识到CLR首先要在GAC中探测组装(我认为这是设计用于签名的组装)。以下是用于快速参考的日志:
我可以通过在GAC中安装程序集使它正常工作-但问题和好奇心仍然存在,为什么在GAC中找不到CLR后,为什么CLR没有从应用程序基本目录中选择它? >
从下面的日志中还可以看到,在GAC之后,搜索是在目录C:Windows / System32与我的应用程序目录下进行的。我认为是因为也有日志说它正在在可执行文件C:\ Windows \ system32 \ dllhost.exe 任何帮助/评论表示赞赏!! *** Assembly Binder Log Entry (6/28/2018 @ 4:18:02 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: All probing URLs attempted and failed.
*** Assembly Binder Log Entry (6/28/2018 @ 4:18:02 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: All probing URLs attempted and failed.
*** Assembly Binder Log Entry (6/28/2018 @ 4:18:03 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
*** Assembly Binder Log Entry (6/28/2018 @ 4:18:03 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : MS.UST.EC.Oem.ServiceProxy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0753af11def5a5f8.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
答案 0 :(得分:1)
EXE映像C:\Windows\system32\dllhost.exe
被称为“ COM代理”主机。如果要激活COM +组件服务,而不是在自己的进程中加载它(出于安全性或稳定性的考虑),将调用dllhost.exe
来加载组件并将其公开为“进程外”激活,然后通过某种透明的代理渠道与您的流程进行通信,从而允许调用程序假装该组件已在本地加载。
这意味着您可能已经通过COM +接口访问了一些代码,并且这些代码正在进程外启动。该代码反过来试图加载Microsoft.IdentityModel.Clients.ActiveDirectory
程序集。问题是,它不再在您的过程中,并且不会参与您设置的任何绑定策略(私有bin路径,绑定重定向等)。这就是为什么您看到它先尝试GAC,然后找不到您的dll的原因-这不是您的进程。
查找您可能正在加载的任何组件,这些组件都是COM组件:您是否正在使用某些COM TypeLib或某个COM dll的运行时可调用包装程序,或者是否有任何继承System.EnterpriseServices.ServicedComponent
的代码?
如果可以找到启动进程外COM组件的位置,则可以重构它以使逻辑进入进程并以此方式解决加载问题。否则,您必须将程序集放入GAC。