Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DLL versioning error

I've got a web site that sporadically throws the following error:

Server Error in '/' Application.

Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Now I know that I do have a dependency on this DLL, but I have version 0.85.5 on my system. I have systematically deleted every older version of the DLL from the server, recompiled everything and republished. But no matter what I do, it seems that after every republish, the first one or two times that someone visits the site, they get this error. Then after refreshing once or twice, the error goes away and the site functions as normal.

What makes it even more weird is if I look at the line of code where the error is thrown:

URLRewriter.ProcessRewritingResult(status, excludedEnum, siteName, viewMode, relativePath);

URLRewriter is a class from a 3rd party package (Kentico CMS - CMS.URLRewritingEngine.dll). I ran Dependency Walker on that DLL and found no dependencies whatsoever on ICSharpCode.SharpZipLib.

Any ideas how to fix this?

EDIT: At @JeremyThompson's suggestion, I ran Process Monitor to catch the error. Here's a screen dump, with relevant pieces highlighted (and one folder name obscured for privacy reasons). You can view it full size by right-clicking on it, etc...

enter image description here

EDIT: Here's a load trace from the error. Does this help?

=== Pre-bind state information ===

LOG: User = MY-SERVER-12\Administrator

LOG: DisplayName = ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 (Fully-specified)

LOG: Appbase = file:///C:/inetpub/wwwroot/MySite/

LOG: Initial PrivatePath = C:\inetpub\wwwroot\MySite\bin

Calling assembly : CMS.WebAnalytics, Version=6.0.4377.2467, Culture=neutral, PublicKeyToken=834b12a258f213f9.

===

LOG: This bind starts in default load context.

LOG: Using application configuration file: C:\inetpub\wwwroot\MySite\web.config

LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG: Post-policy reference: ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/9760eb69/275bb3db/ICSharpCode.SharpZipLib.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/9760eb69/275bb3db/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.DLL.

LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib.DLL.

LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/9760eb69/275bb3db/ICSharpCode.SharpZipLib.EXE.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/9760eb69/275bb3db/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.EXE.

LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib.EXE.

LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.EXE.

like image 493
Shaul Behr Avatar asked Jul 15 '12 07:07

Shaul Behr


People also ask

How do I fix dll errors in Windows 10?

If DLL files are missing on your Windows 11/10/8/7 computer, the best ways to fix such errors are as follows: Run the built-in System File Checker tool to replace missing or corrupted operating system files. Run the DISM tool and repair the Windows system image and fix a corrupted Windows Component Store.

How do I change a dll Version?

For a file that is missing version info completely: After opening the DLL in Visual Studio, go to Edit > Add Resource > Version and click New. Then in the new Version tab, change FILEVERSION and PRODUCTVERSION, CompanyName, etc. Save the files and you're all set!

Where can I find dll Version?

In File Explorer when you right click the dll file and select properties there is a "File Version" and "Product Version" there.

What is Version dll file?

The file version. dll contains program code used by windows to perform version checking on other libraries and other supporting files. The ver. dll library is required for Windows to function correctly.


2 Answers

Now I know that I do have a dependency on this DLL, but I have version 0.85.5 on my system. I have systematically deleted every older version of the DLL from the server, recompiled everything and republished.

Sounds like the 'dependency' is expecting the OLDER version of the DLL. Why not REPLACE all copies of the NEWER version (0.85.5) on your system, with the OLDER version (0.85.3.365)? (Make sure to check both the 'bin' folder of your web application and the 'GAC': c:\windows\assemblies)

If you need, you can download the older version here: http://sourceforge.net/projects/sharpdevelop/files/SharpZipLib/0.85.3/

NOTE:

  • After replacing the DLL, stop IIS and clear all Temporary ASP.Net files. E.g.: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
  • ALSO: Remember to update your Visual Studio Solution so that it references the older version.

Cheers

Pete

like image 137
Peter Avatar answered Sep 22 '22 10:09

Peter


So it turns out that Kentico has its own dependency on ICSharpCode.SharpZipZip.dll - and it's expecting to find the older version. I found a similar solution here. By inserting the following block into my web.config file, it seems I have finally banished this error!

<runtime>
  <assemblyBinding>
    <dependentAssembly>
      <assemblyIdentity name="ICSharpCode.SharpZipLib" publicKeyToken="1b03e6acf1164f73"/>
      <bindingRedirect oldVersion="0.85.3.365" newVersion="0.85.5.452"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

What I still don't understand is, why didn't Dependency Tracker show up this dependency?

EDIT: Oh dear, this didn't solve it after all. It seems to happen less frequently now, but after restarting IIS today, one of our testers got the old error message again! :-(

like image 35
Shaul Behr Avatar answered Sep 20 '22 10:09

Shaul Behr