Fix for ASP.NET "Could not load file or assembly App_Web…" Error

Every so often on our production web servers, we get the "Could not load file or assembly App_Web…" error.  There's a long thread over at ASP.NET about this issue, but I thought a simple post may help others running into this problem.

I've found an quick and easy, albeit not ideal fix for this problem.  There's supposedly a hotfix for this, but there are reports that this won't actually fix the error.  Until a good long term fix comes around, here's a quick way to fix this problem. 

Delete all temporary ASP.NET files, by removing the folders under the following directory: 

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\

Your mileage may vary (win directory differences, etc)

-Brendan 

About Brendan Tompkins

Brendan runs CodeBetter.Com and Devlicio.Us. He is a former MVP for Microsoft .NET and is president of Port Technology Services, a partner with Port Solution Integrators a provider of hardware and software integration services for the transportation and logistics industry.
This entry was posted in ASP.NET. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Stefan

    Thank you very much, Brendan, this fixed my issue. Regards, Stefan

  • Lyall

    Did the trick, thanks dude!

  • http://www.facebook.com/christopher.d.thomas.75 Christopher David Thomas

    Thank you very much for this solution, worked perfectly in my case after changing the details to match the .NET version and architecture I am using.

    For anyone interested, my issue occurred after my server unexpectedly crashed.

  • Perdido09
  • Shadowsurfs

    Umm, yeah. This solution is complete BS. Sorry, not really a solution as much as a crappy bandaid that will only work in certain situations.

  • Alexis_tf

    this is not a correct fix for this problem, you better stay as a disco dancer full time.

  • Jack

    I agree it is too late to delete the temp file after the problem alreay happen.

    Have you found a better solution?

  • Simdrouin

    This solution works when there actually is a problem (which is, generally speaking, too late), however what if we are looking avoid this situation in the first place ?

    Is there some way we could force asp.net to not use the files in the temporary asp.net folder ?

  • Afnan_70

    Good One Really Worked For ME !!!!!!!

  • http://suncat2000.myopenid.com/ GetSmart

    If you are on a 64-bit platform, you want to remove files from the …Framework64… folders, too.

    If you have updated to .NET 4.0, the current paths are C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files and C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Files.

  • Prantik

     u may want to delete the temp files from %appdata% folder as well. It worked for me

  • Azhar

    Well, I am not a developer but I got to deploy a project which actually send fax using the fax services on windows 2008 server 64bit. the project was developed on a windows 32bit platform and I was setting all the information according to the given instruction but still I this annoying error and then I found the solution and that was to change the platform from anycpu to x86 and it worked. for a complete setting list please follow the link below:
    http://www.sizledcore.com/2011/10/could-not-load-file-or-assembly/

  • Jack

    I have no such directory (

  • Kolay Mike
  • Pallavi

    It will work only if u r working with IIS but not a fix for the problem if the same error occurs while hosting it on ur web server…. Is there any other solution since I am still stuck with same problem …
    Thanks

  • Guest

    It worked in my case. Thanks!

  • Brian

    Doesn’t really work

  • Nomyleh

    Good article.It helped me

  • Richb01

    This was exactly the issue I saw. Thanks!

  • http://tomkrueger.wordpress.com Tom

    I remember this problem from a long while back but forgot today. It just happen to run into it this issue again and your post is still continuing to help. Thanks much.

    Tom

  • Paul Zeitchick

    Axel Hofmann – you saved me. After days of fighting with this problem, you had the answer. I had my dlls in /bin off of a sufolder. Moving them to the root/bin solved my problem. Thank you

  • Axel Hofmann

    Due to html-translation, made the article above is hard to understand, so once again:
    I fought this issue yesterday.nothing in here actually helped me. but then I read Chrstophers again adn got. I had called the website through the physical address (localhost//website.aspx.

    Seems the application could not find the precompiled dlls.

    So I tried something else: I changed the port of the binding to 82 and called localhost:82/website.aspx. BINGO! It worked. So it seems .net is looking for the assemblies in the root/bin directory. If you deploy to subdirectory, you have to take care of this issue.

    hope i could help someone.

  • Axel Hofmann

    I fought this issue yesterday.nothing in here actually helped me. but then I read Chrstophers again adn got. I had called the website through the physical address (http://localhost//website.aspx.
    Seems the application could not find the precompiled dlls.
    So I tried something else: I changed the port of the binding to 82 and called http://localhost:82/website.aspx. BINGO! It worked. So it seems .net is looking for the assemblies in the root/bin directory. If you deploy to subdirectory, you have to take care of this issue.
    hope i could help someone.

  • http://www.sanshark.com Sandesh Daddi

    What I did is I changed in web.config as

    to

    RAN THE APPLICATIOn

    and again

    thank you
    sandesh daddi
    http://www.sanshark.com

  • Jing Tang

    Worked for us as well after deleting everything in the temp folder!

    Thanks:)

  • http://www.ajsquare.com/products/helpdesk-software/admin-side-features.php Harry

    Thanks for the suggestion. It works good to me too.

  • EricB

    I started getting this error after an out of memory error and a reboot.
    Deleting the folders and files in this directory worked for me.

    Thank you Brendan!

  • http://www.mlb-uk.co.uk Christopher White

    What I had was a directory structure as follows : root folder (which has it’s own bin folder ) and then website folder in which rthere was another bin folder. Obviously publishing from VS 2008 it published the dll’s into the the website folder bin instead of the root folder bin. I copied the dll’s from the website folder bin to the root folder bin and it works… Came across this issue with other applications so this may not work for you, but may be worth a try :)

  • NEILY

    WORKED FOR ME!

  • http://ifirezitybuk.livejournal.com/1353.html how fast does infant motrin work

    Buy how fast does infant motrin work online. how fast does infant motrin work. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://agisafysuvyt.livejournal.com/755.html mix tylenol and motrin children

    Buy mix tylenol and motrin children online. mix tylenol and motrin children. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://aqyhukecujiw.livejournal.com/1013.html cvs – cost of 60 tabs of motrin 800mg

    Buy cvs – cost of 60 tabs of motrin 800mg online. cvs – cost of 60 tabs of motrin 800mg. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://agisafysuvyt.livejournal.com/816.html infants motrin

    Buy infants motrin online. infants motrin. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://yzevivejiral.livejournal.com/644.html how to counteract stomach upset from motrin

    Buy how to counteract stomach upset from motrin online. how to counteract stomach upset from motrin. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://itogelozylyx.livejournal.com/1229.html motrin 800 mg

    Buy motrin 800 mg online. motrin 800 mg. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://uzyvapujibol.livejournal.com/858.html children’s motrin coupon

    Buy children’s motrin coupon online. children’s motrin coupon. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://uzyvapujibol.livejournal.com/664.html can you take tylenol and motrin at the same time for pain

    Buy can you take tylenol and motrin at the same time for pain online. can you take tylenol and motrin at the same time for pain. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://odavatusuruv.livejournal.com/979.html no motrin and spinal fusion

    Buy no motrin and spinal fusion online. no motrin and spinal fusion. No Prescription. We accept: VISA, MasterCard, E-check, AMEX and more.

  • http://messeiry@msn.com Mohamed ELMesseiry

    i had the same problem and the solution is to upload the files again then restart iis on the server.
    nd it will work

  • http://messeiry@msn.com Mohamed ELMesseiry

    i have found a solution for this. you are propably getting this error from a specific page.

    upload the files again to the server. then restrt the IIS. and it will work.

  • mabra

    Hi !

    I have the problem also. The only fix is re-compile or delete temp. The latter is horror, because the web must be stopped. The mentioned fixes won’t install [I am using x64]. The temp files must be deletes for my WCF service all two minutes!!!!!

    br–mabra

  • Amit

    Hi,

    I have tried each and every option mentioned here but still i m in mess…..It seems that app_web_*****.dll are for design only and if take everything except these dlls from bin and deploy the same on server it works(Not confirmed)……but major concern is how to get rid of these dlls….let me know if anyone have tried anything else…thanks

  • Veles

    sorry for my English.. I learn it only serveral weeks. So..

    I have in App_Code some utility class which used in code-behind. When I had added static method which use my assembly and “using” directive for it, I got this error.

    In my case was reason in this using directive

  • veles

    sorry for my English.. I learn it only serveral weeks. So..

    I have in App_Code some utility class which used in code-behind. When I had added static method which use my assembly and “using” directive for it, I got this error.

    In my case was reason in this using directive

  • ave

    nothing seems to work for me…….its very annoying…

  • THE-ORACLE

    I’ve faced this problem before the representation of my graduation project (B cs) by one day.
    I deleted the temporary files as you said but I needed to CLEAN THE PROJECT ( Build -> CLEAN PROJECT) then it worked nicely.
    Thanks to all, and I hope you find your solution.

  • http://ahref=http://www.krojamsoft.com/filecleaner.phphttp://www.krojamsoft.com/filecleaner.php/a sdf
  • GB

    Thanks a lot !!! it works by deleting the files. Those with probs after deleting can try getting latest versions of the following files

    - Aspnet_wp.exe
    - System.web.dll
    - Webengine.dll
    lower version or higher version can be the cure:
    see
    http://support.microsoft.com/kb/915782/en-us

  • http://www.yetanotherdeveloper.com Joey
  • Kevin

    Worked like a charm. Great post!

  • seaquel

    You are the hacker, thanks a lot, you save my time : )

  • http://vtic.vn trungtd

    Thank for share. I’m Fixed

  • Mark

    I got this error because I had built a website in Visual Studio 2005 using the AJAX – enabled template that you get when you install the AJAX add-on for ,NET 2.0

    When I came to publish the website I had forgotten to set up the folder on the web server as a virtual directory, I had just created a folder inside c:\inetpub\dev on the web server and copied the content in. So what I did was delete the folder and then create a ‘proper’ virtual directory using the IIS admin tool (i.e. Start –> Run –> inetmgr). This seemed to resolve the problem for me – although I did delete the temp folders as originally suggested and made some of the changes to the web.config file too so it could have been a combination of things.

  • http://www.softlion.com Softlion

    Add the batch=false attribute to your web.config ‘compilation’ tag :

  • http://www.mesync.com Jake M

    I had the root folder configured as a virtual directory to run asp.net application.

    The problem was I didn’t create the virtual directory under the root thus asp.net was running but couldn’t find the correct location of the bin folder.

  • http://www.akkanson.com Ray Akkanson

    Yah, I’ve gotten that a bunch actually. Usually it’s b/c of temp files. Clear your temp directory and give it another try. What’s happening is that the temp file name generated when the assembly is loaded exceed 255 characters. So it’s truncated. That in turn means that what it’s trying to access doesn’t exist.

    Here’s a related support kb addressing the issue: http://support.microsoft.com/kb/823196

    Also, set the compilation directory’s tempDirectory property specifically. You can point it to C:\whatever or some shorter path name than it normally would use and thereby not have the really long path name problem.

    Ray Akkanson

  • Aysha

    thanx a dozenn ………..it worked by deleting files from TempASP.Net files!!
    :D

  • Marco

    To resolve the problem, I also took care to use the correct version of the .NET framework:
    1. Go to Internet Information Services
    2. Go to the virtual directory, right click on it and go to Properties
    3. Go to ASP.NET tab, and choose 2.0.50727 in ASP.NET version

    Hope this helps

  • http://indianescapes birju

    thanks

  • Gopi

    Verify the Project property

    project property –> build–>platform target

  • Matthew

    Here’s how I created and then fixed this problem. I hope it helps someone.

    I changed the name of a file.
    Then I went in and manually changed the top statement in the aspx (I use separate c# code files) to reflect the proper: 1) ‘inherits’ statement and the ‘codefile’ variable.

    I neglected to change the class name in the .cs file.

    That was what CREATED the error.

    To fix it? I renamed the class name in the .cs file to correspond with my other renamings and… voila. No more app_web errors.

    Is this helpful?

  • http://jacekciereszko.pl Jacek Ciereszko

    Thanks, You helped me :)

    I work with Silverlight and WCF Services and I have often this stupid error :/

  • http://ajsquare.com prabhaharan

    thanks a lot. its working…

  • Rajambal

    Thanks a lot … sir.. It solved my problem.

  • Ron Kuper

    It’s 4:14 AM here in Israel and I LOVE YOU SO MUCH Brendan!!!!!!

    I LOVE YOU I LOVE YOU I LOVE YOU I LOVE YOU!!!

  • mark borg

    Hi guys maybe it could help someone. I had the same problem and what fixed the problem is to :

    (1) Remove the AJAX DLL from the references
    (2) Add the same AJAX DLL again as a reference
    (3) Rebuild the project

    i cannot assure that it works, but i worked for me

    good luck

  • http://itfact.blogspot.com Ahmad

    ohhh..yes it solved my problem…helpful….i was hanged by this problem…
    Thank you….

  • Sean

    Thanks, this seems to have fixed it for me…

  • native

    Thank you, it worked for me too.

  • Laura

    What if i get the error but the folder mentioned above is empty?
    How can i fix it in this case?

  • linxiang

    Sometimes that we cann’t do this action,because we have no acces to the web server.

  • http://www.calistomind.com/ Jay

    A quicker fix would be to enable/disable the “Enable Debugging” checkbox in IIS under ASP.NET > Edit Configuration > Application

  • Fakur

    Thank you so much..
    After a year this artikel. I got similiar problem, and it has been resolved.

  • Prakash

    Thank you very much for providing solution. It has resolve my similar issue.

  • Hanno

    I copied over the new dll’s to wherever they appear in the project, I’ve reregistered my references, I’ve deleted my temp files, and STILL, the old version is stuck somewhere. I can’t figure out where. This is SO frustrating!

  • ian blair

    my error “could not load file or assembly comes up when i start the computer so is not a big problem but an annoyance, checked in the temporary ASP.net files and there was none to delete so fix did not work for me , thanks in advance.

  • http://www.nilpa.com Lata

    Its’ work for me……….Thanks a lot!!!

  • http://www.nilpa.com Lata

    Good!!

    It’s work for me..m getting this headache from half of the day…thanks…a lot :)

  • Rob

    Just case other people come across this problem and they are using .net 2 to write their app, make sure your IIS setting isn’t using 1.1 !!! (yes I know!)

  • D@

    We have an app being used by our university and this error suddenly shown up after moving to a new server. After months trying every possible solutions from the web… none working for us. Finally, last week the error disappeared completely after we undo the default pool recycling in our IIS . Hope this would help someone with the same problem.
    Cheers,

  • Dave

    I’ve never gotten an error like this running classic ASP – it has 100% up time. Running SiteScope just to make sure. Should I just skip asp.net 2.0 and wait for a fix. I need to be up 100% of the time. Perhaps this is only related to the compile at runtime style deployment vs. the Asp.net 1.0 approach of precompiling everything.

  • jrush

    I can’t believe that MS hasn’t provided a real solution for this problem yet. The solution listed here is only a temp solution, but I’ve only experienced this problem with sites using master pages & nested user controls. Is this the case for everyone else?

  • Sammael Cavalera

    Para arreglar este error :

    Una vez que se publique el Sitio Web, hay que ir al: Servicios de Internet Information Server (IIS), desplegar el menu de la parte izquierda, en este menu donde dice: Sitio Web Predeterminado crear un nuevo Directorio Virtual, se sigue los pasos , se pone un Alias (puede ser el mismo nombre con el que se publico nuestro Proyecto), luego donde sale escoger el directorio, escogemos nuestro sitio web que acabamos de publicar y poner siguiente, siguiente, las opciones que salen por defecto.

    Luego ponemos en el URL del Internet Explorer la dirección de nuestro sitio y ya no saldra el error.

    En mi caso (trabajando con: Microsoft Visual Studio 2005 y AJAX), con esto pude arreglar el problema de: Could not load file or assembly App_Web …

  • Gavin

    If we’re talking about the same error, I’ve been getting this for years. If you delete temporary files (or, as the asp.net forum mentions, make a small change to the user control indicated in the error), you force a recompile, and the error goes away. The *error* goes away, but not the *problem.*

    A real “fix” would prevent the problem from occuring — which it does only sporadically. I don’t know how to reproduce this bug, nor of anyone else who does. MS can’t do anything about it, after all, until it’s reproducible.

  • fff

    not worket for me

  • Grig Gheorghiu

    Thanks, Brendan! I got paged at 5:30 AM by one of our ASP.NET sites, and Google + your blog post proved invaluable in getting things up and running again!

    - stopped WWW Publishing service
    - deleted temp files you specified
    - started WWW Publishing service

    Thanks again!

    Grig

  • Darpan

    Delete the Line in which the assembly is loaded from web.config

    It has worked for me nothing else was working for hours.

  • Madhu

    thanks alot…it works.
    I was hooked with this error for two days…

    Good work..

    cheers
    madhu

  • btompkins

    Hmm.. Are you deleting everything from this directory successfully?

  • Toby

    nor me – this is one big problem it seems. Have tried endless reconfiguration after upgrading to the latest ajax asp.net version, but it has completely broken my application…

  • david

    It didnt work for me.