Click here to Skip to main content
15,887,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I did a simple ajax services (json based) to get some data from database.
The problem stated below:

On localhost: while programming/editing the aspx page in visual studio and seeing the result in browser it works fine for say 5-6 times of editing the aspx page, and then just start failing. Until I go to my web service interface class do something (say just put a newline somewhere) and recompile it. The problem get fixed and the cycle goes on...

When I trace the failed requests in fire bug I found 500 internal server error:
[FileNotFoundException: Could not load file or assembly 'App_Web_lbgnha4m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
*can give the stack trace if required.

I am not sure, but looks like this file 'App_Web_lbgnha4m' is generated temporary because everytime I fix this error by recompiling the code. After some time it again comes back with new name 'App_Web_blahblahblah'

My biggest concern is that when I deploy the solution to my staging server. the service worked fine (say for a day) and then same error, quite surprised what goes wrong without touching a file once deployed). Obviously I can’t deploy the solution every day to fix this....

Any suggestions please help......


Full Stack Trace:

[FileNotFoundException]: Could not load file or assembly 'App_Web_lbgnha4m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
[ServiceActivationException]: The service '/Website/RESTfulService.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not load file or assembly 'App_Web_lbgnha4m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified..
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext)
   at System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Posted
Updated 24-Jul-11 21:56pm
v3

Hi,

For your information, the assembly App_Web_xxxxxx is the dynamically compiled assembly from your not-compiled ASP.NET Code. This assembly will be generated when you use the "New Website" command in VisualStudio rather than "New Project" => "ASP.NET Web Application".

This seems to be an old bug in ASP.NET 2.0 Framework and I found a forum post where they discuss about this:
http://forums.asp.net/t/986130.aspx/1?Could+not+load+file+or+assembly+App_Web+[^]

Perhaps this post could help you:
http://forums.asp.net/t/986130.aspx/7/10?Could+not+load+file+or+assembly+App_Web+#1620645[^]

=== from the post: ===

It seems there’s a timing issue when app domains shutdown and then startup where the appdomain deletes a file from temp asp.net files folder that the new app domain just created.

As mentioned, we hope to have a fix for this shortly – but one workaround that has worked for the other case was to increase the numRecompilesBeforeAppRestart to 50 (default is 15). This is in the web.config for the application.

HTML
<compilation
     defaultLanguage="c#"
     debug="false"
     numRecompilesBeforeAppRestart="50"
/>


===

Hope this helps.

Best regards and happy coding,
Stops
 
Share this answer
 
Comments
saxenaabhi6 28-Jul-11 1:36am    
What a find man great....
I have been to all the forums and looks like i missed the one you found out.
I wonder it's an old problem of 2007-2008s and still coming in my VS2010.
let me try this and will be back with an update...
Thanks a ton
Christoph Keller 28-Jul-11 3:14am    
you're welcome, hope this helps really! :)
saxenaabhi6 28-Jul-11 3:17am    
its definitely helping, services are still working on my localhost, may hit an error after 50 edits i think :P, but still life is much easier now. Thanks
Christoph Keller 28-Jul-11 3:21am    
That's good to hear!
You're welcome :)
Hi,

Please post the complete Stack information. Are you getting this problem on any specific time of a day ?


Thanks,
Balaji Prabu
 
Share this answer
 
Comments
saxenaabhi6 25-Jul-11 3:57am    
no specific time..
Some hope on deployed solution on web server....
if I stop the website, recycle the application pool, remove all .Net temporary files and then restart the website...
looks like the problem is fixed on deployed solution as I am testing daily (3 days gone), the services are not throwing any error yet.

BUT what about my localhost, Any helps???
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900