I recently faced this problem with one of my WCF services, i was unable to find the reason for this as it complains that it could not load an assembly which in my case never existed.So seeing the error i knew that it was not my fault but it was the fault of the framework itself. What i know and what seemed to me is that this error occurs due to some invalid data in the temporary files which .net creates while running an application.Due to the differences in the code of the temporary files from the actual code this error arises. Little help from Google suggested me that it’s a known issue and Microsoft has not yet found any fix for this situation although there are a few workarounds which you can do in order to escape from this problem. In this article i will discuss those workarounds and remember there is no specific workaround so you have to test all whichever may suite you.

  • First of all just try this one and see if it works then its the easiest, just make a note of whichever control is causing trouble to you it could be your masterpage, you usercontrol or your web service or WCF service.Just go to that control or service and simply edit something, just deleting a small space or pressing an enter key and deleting some white spaces would do and save the document, what this will do is it will ask the runtime to regenerate the temporary file and the regenerated temporary file will be correct as earlier somehow the temporary file generated for this file was incorrect.So most of the times this would do the trick especially in case of services.
  • If the first solution doesn’t help you then you can go to c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files and delete all the files and force a complete recompile of the whole application.You have to be very careful in deleting the temporary files and don’t try this on the production server this tip is for those who know about the working of .net.If some files are locked then you can unlock them using “Unlocker
  • If the above 2 steps don’t work for you then add the batch= “false” compilation tag in your web.config

I think these three steps are sufficient to overcome this problem. Moreover one thing which i want to add is that never directly start updating your production website with the new updates by just copying the new files on the production server, before copying just take the website down i.e pause the website and once your are done with your changes again put the website to go live or else you will run into this trouble every now and then. If you have faced similar problems and you found some other solution or cause to this problem you can just share it here with smallworkarounds readers to help the community. Happy Programming!!!!!!!!!!!!!!!!!!