https://indexoutofrange.com/Could_not_load_file_or_assembly_or_one_of_its_dependencies/
Reading assembly binding log files (Fusion Log)
This is my preferred way to diagnose. After dealing with many Microsoft loggs, I think the assembly binding ones are the best ones. The files are named using a pattern like this:
[assembly name], Version=[assembly version], Culture=[culture], PublicKeyToken=[public token]
so for NLog we will have:
NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c
The best way to understand how .NET runtime loads assemblies let’s look at the logs.
The operation completed successfully.
First an easy one - the one that succeeded.
The operation failed.
Now for something harder, but more interesting. A failed log file. Also for NLog.
Troubleshooting FusionLog
I don’t see the logs from my application
The application has to be restarted after enabling the log. When talking about IIS application the whole IIS process has to be restarted.
I don’t see the folder
You have to create the folder manually
The application runs slower
The logging adds some overhead, but not enough for it to be seen with a bare eye. Maybe You are doing a lot of dynamic assembly loading?
Something is eating up my disc space
Disable the log. When enabled it creates a lot of small files. The result is that they are taking up more disc space than they actual size.
The logs are still being created despite disabling the logging
Restart the application process.
Why is it called fusion log?
I suspect because fusion is the process of combining two atoms into one.
实例分析
*** Assembly Binder Log Entry (4/30/2020 @ 10:55:30 AM) *** The operation failed. Bind result: hr = 0x80131040. No description available. Assembly manager loaded from: C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll Running under executable c:windowssystem32inetsrvw3wp.exe --- A detailed error log follows. === Pre-bind state information === LOG: DisplayName = ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 (Fully-specified) LOG: Appbase = file:///D:/Project/IN_LS_CMS_WDAL/ LOG: Initial PrivatePath = D:ProjectIN_LS_CMS_WDALin LOG: Dynamic Base = C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Filesin_ls_cms_wdale4b0d765 LOG: Cache Base = C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Filesin_ls_cms_wdale4b0d765 LOG: AppName = 214332ee Calling assembly : CMS.IO, Version=7.0.5354.21097, Culture=neutral, PublicKeyToken=834b12a258f213f9. 所以是CMS.IO调用了ICSharpCode.SharpZipLib === LOG: This bind starts in default load context. LOG: Using application configuration file: D:ProjectIN_LS_CMS_WDALweb.config LOG: Using host configuration file: C:WindowsMicrosoft.NETFramework64v4.0.30319aspnet.config LOG: Using machine configuration file from C:WindowsMicrosoft.NETFramework64v4.0.30319configmachine.config. LOG: Post-policy reference: ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/in_ls_cms_wdal/e4b0d765/214332ee/ICSharpCode.SharpZipLib.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/in_ls_cms_wdal/e4b0d765/214332ee/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.DLL. LOG: Attempting download of new URL file:///D:/Project/IN_LS_CMS_WDAL/bin/ICSharpCode.SharpZipLib.DLL. LOG: Assembly download was successful. Attempting setup of file: D:ProjectIN_LS_CMS_WDALinICSharpCode.SharpZipLib.dll LOG: Entering download cache setup phase. LOG: Assembly Name is: ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: The assembly reference did not match the assembly definition found. ERR: Setup failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
*** Assembly Binder Log Entry (4/30/2020 @ 10:55:30 AM) *** The operation failed. Bind result: hr = 0x80131040. No description available. Assembly manager loaded from: C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll Running under executable c:windowssystem32inetsrvw3wp.exe --- A detailed error log follows. === Pre-bind state information === LOG: DisplayName = ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 (Fully-specified) LOG: Appbase = file:///D:/Project/IN_LS_CMS_WDAL/ LOG: Initial PrivatePath = D:ProjectIN_LS_CMS_WDALin LOG: Dynamic Base = C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Filesin_ls_cms_wdale4b0d765 LOG: Cache Base = C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Filesin_ls_cms_wdale4b0d765 LOG: AppName = 214332ee Calling assembly : CMS.IO, Version=7.0.5354.21097, Culture=neutral, PublicKeyToken=834b12a258f213f9. === LOG: This bind starts in default load context. LOG: Using application configuration file: D:ProjectIN_LS_CMS_WDALweb.config LOG: Using host configuration file: C:WindowsMicrosoft.NETFramework64v4.0.30319aspnet.config LOG: Using machine configuration file from C:WindowsMicrosoft.NETFramework64v4.0.30319configmachine.config. LOG: Post-policy reference: ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/in_ls_cms_wdal/e4b0d765/214332ee/ICSharpCode.SharpZipLib.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/in_ls_cms_wdal/e4b0d765/214332ee/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.DLL. LOG: Attempting download of new URL file:///D:/Project/IN_LS_CMS_WDAL/bin/ICSharpCode.SharpZipLib.DLL. LOG: Assembly download was successful. Attempting setup of file: D:ProjectIN_LS_CMS_WDALinICSharpCode.SharpZipLib.dll LOG: Entering download cache setup phase. LOG: Assembly Name is: ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: The assembly reference did not match the assembly definition found. ERR: Setup failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
ICSharpCode.SharpZipLib