I'm working with a few different WCF REST services for some demo code and I've been getting an inconsistent error, every few hours. I've been getting the old "Could not load file or assembly... or one of its dependencies. The system cannot find the file specified" errors when accessing the WCF .SVC file in an ASP.NET hosted WCF service:
The odd thing about the error is that it only occurs with the Web Service (.SVC) file - the rest of the application and ASPX pages seem to work fine. The assembly in question always points at a dynamically compiled file that starts with App_Web_xxxxx that is a result of ASP.NET's dynamic compilation.
I'm using Web Application Projects (WAP), which require full re-compilation of all CodeBehind code before any code can execute. Yet, even through I do a 'Build' in Visual Studio that I get this apparent assembly versioning error.
The pisser about this is that this error is triggered 'hidden' when making an AJAX callback that's trying to access the service. The page loads and then fails with client script errors that fail to load the ASP.NET AJAX proxy script code (ie. the /jsdebug call fails to load the javascript proxy code).
Luckily there's a fix: Do a full recompile (Rebuild All in Visual Studio) of the entire project after which the service works just fine. It's a FULL recompile that's required though. If I just do a regular incremental build - no good. If I just do a compile the Web WAP Project - no good. All four projects have to be recompiled.
Unfortunately the error always ends up returning, even though nothing else has changed - none of the other project dependencies are updated yet the recompile fixes the problem. My first thought is that it's one of those rare problems where the ASP.NET temporary file folder gets hosed, but even restarting IIS doesn't solve this particular problem either.
So, I enabled the Fusion Logs to check out what's failing to load. To so I opened up the fusion log viewer (fuslogvw.exe from the Windows SDK) enabled Fusion logging and provide full assembly linking information in a log file.
*** Assembly Binder Log Entry (4/7/2008 @ 12:22:39 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = App_Web_cueuyz3g, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/projects2008/Articles/WcfAjax/WcfAjax/
LOG: Initial PrivatePath = C:\projects2008\Articles\WcfAjax\WcfAjax\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\wcfajax\3a2866fa
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\wcfajax\3a2866fa
LOG: AppName = 6c86f508
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\projects2008\Articles\WcfAjax\WcfAjax\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Aspnet.config
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: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
Nothing helpful here really. It just seems to indicate that the application is looking for a dynamic assembly that - for whatever reason even after a Web project compile - is no longer there.
The question that bugs me though: Is it just a condition that occurs because one of the markup pages (the SVC or ASPX pages) are changing or is the problem more involved where an ASP.NET forced recompile can introduce this problem. IOW, is this just a development problem or something that can rear its ugly head in live deployment? Since it's so inconsistent and only occurs every few hours or so it's hard to do a lot more discovery on this issue.
Incidentally the service is the only thing that doesn't work - the ASP.NET pages that use the same business objects and other project assemblies work just fine.
Anybody ever seen this particular problem?
Other Posts you might also like