title: DLL versioning error
body: <p>I've got a web site that sporadically throws the following error:</p>
  
  <blockquote>
    <p>Server Error in '/' Application.</p>
    
    <p>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)</p>
  </blockquote>
  
  <p>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 <strong>every</strong> 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.</p>
  
  <p>What makes it even more weird is if I look at the line of code where the error is thrown:</p>
  
  <pre><code>URLRewriter.ProcessRewritingResult(status, excludedEnum, siteName, viewMode, relativePath);
  </code></pre>
  
  <p><code>URLRewriter</code> is a class from a 3rd party package (<a href="http://www.kentico.com/" rel="nofollow noreferrer">Kentico CMS</a> - CMS.URLRewritingEngine.dll).  I ran Dependency Walker on that DLL and found no dependencies whatsoever on ICSharpCode.SharpZipLib.</p>
  
  <p>Any ideas how to fix this?</p>
  
  <p><strong>EDIT:</strong> 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...</p>
  
  <p><img src="https://i.stack.imgur.com/TFQSR.png" alt="enter image description here"></p>
  
  <p><strong>EDIT:</strong> Here's a load trace from the error.  Does this help?</p>
  
  <blockquote>
    <p>=== Pre-bind state information ===</p>
    
    <p>LOG: User = MY-SERVER-12\Administrator</p>
    
    <p>LOG: DisplayName = ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
     (Fully-specified)</p>
    
    <p>LOG: Appbase = file:///C:/inetpub/wwwroot/MySite/</p>
    
    <p>LOG: Initial PrivatePath = C:\inetpub\wwwroot\MySite\bin</p>
    
    <p>Calling assembly : CMS.WebAnalytics, Version=6.0.4377.2467, Culture=neutral, PublicKeyToken=834b12a258f213f9.</p>
    
    <p>===</p>
    
    <p>LOG: This bind starts in default load context.</p>
    
    <p>LOG: Using application configuration file: C:\inetpub\wwwroot\MySite\web.config</p>
    
    <p>LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config</p>
    
    <p>LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.</p>
    
    <p>LOG: Post-policy reference: ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73</p>
    
    <p>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.</p>
    
    <p>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.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib.DLL.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.DLL.</p>
    
    <p>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.</p>
    
    <p>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.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib.EXE.</p>
    
    <p>LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySite/bin/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.EXE.</p>
  </blockquote>