Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net

wcf

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!

like image 448
Kram Avatar asked Apr 04 '11 12:04

Kram


People also ask

Why am I getting ‘could not load file or assembly’ errors?

Especially while installing a new dev machine, and building your project for the first time, you may end up getting the following exception: Could not load file or assembly ‘ [assemblyname]’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

What does “an attempt to load a program with an incorrect format” mean?

The latter part of the error message should point you to the right direction. “An attempt was made to load a program with an incorrect format.” That means that the assembly, which was to be loaded, was in an unexpected format.

What does it mean when an assembly is in unexpected format?

That means that the assembly, which was to be loaded, was in an unexpected format. The format, in this case, refers most likely to 64-bit build of an application being deployed to IIS, which is being run in 32-bits. Why do I think that’s the case?


1 Answers

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

like image 114
amit Avatar answered Oct 20 '22 14:10

amit