Wcf – Could not load file or assembly App_Web_xxxxxxxx or one of its dependencies

asp.netwcf

The full error is:

Could not load file or assembly 'App_Web_xxxxxxxx, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Where xxxxxxxx is the ASP.Net generated temp name.

We are getting this error for a WCF service hosted within an ASP.Net application.

The weird thing is that it happens very occasionally, independent of deployment changes… and when it does happen the service "breaks" for all subsequent requests.

At the moment, the workaround for us at the moment is to delete the temporary assemblies from the application's folder in:

%windir%\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files

The app is hosted in IIS7 on a win 2008 server, using .Net 3.5

Any ideas most appreciated!

Best Answer

This may be the issue with ASP.NET compiler when having .SVC within ASP.NET application. You can avoid the issue by turning off the batch compilation i.e. add following in Web.Config under <system.web> element,

<compilation batch="false">

Please find the steps to repro the issue,

a. Create a ASP.NET website application and add WCF Service (in this example EPOCS002.svc)
b. Set the “repro-website” directory as the root of a new site (I set it up on IIS 7.5 in classic 
pipeline, 32-bit worker process, .NET 2.0 SP2/3.5SP1, with anonymous authentication enabled).
c. Recycle the application pool for the site.
d. Browse default.aspx
e. Browse EPOCS002.svc
f. Edit default.aspx in some way (add a space somewhere) and save it.
g. Browse again to default.aspx
h. Recycle the application pool for the site.
I. Browse again to default.aspx
J. Browse again to EPOCS002.svc

P.S. Microsoft is investigating the cause of the issue at this moment and I'll update the post when I've some information.

HTH, Amit