Fixing .NET error HRESULT: 0×80070057 (E_INVALIDARG)

16 Aug 2007 by Dan,

HRESULT: 0x80070057 (E_INVALIDARG)As is often the case with Windows Vista, my laptop crashed today while I was working on some code for a .NET 2.0 website. Unfortunately this happened while the site was building from a previous change. In case you’re not familiar with how .NET does this, here is a quick overview:

  1. .NET realizes that you’ve rebuilt a dll, and as a result the whole application needs to be recompiled
  2. .NET shadow copies the dll’s from your website’s bin folder into a seperate .NET framework directory
  3. .NET completes compilation and serves the website via IIS

Unforutunately, if your computer dies or crashes during this shadow-copy stage you’re in trouble. The specific error is “Exception from HRESULT: 0×80070057 (E_INVALIDARG)”.

To fix it, you need to get rid of the files that were corrupted during the interrupted file copy:

  • Find the .NET framework complilation folder (in my case it was: “C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files”)
  • Delete all folders other than “root”
  • Open up the “root” folder and delete all subfolders
  • Pull your website up in the browser
  • It should compile successfully and load the website.

Special thanks to my co-worker Patrick for figuring this out.

12 Comments

  1. Mohamed Mostafa says:

    Thank You That was really helpful

  2. ecards says:

    Really needed this - thank you for the solution -
    LTG

  3. possiblybob says:

    Thanks for this tip. It was really useful when I ran across this issue on an ASP.NET 2.0 site.

  4. Infopex says:

    Thanks for this solution, relly useful :)

  5. marten577 says:

    Please Help:

    My configuration: -Visual Studio 2008
    -Solution contains a Web project
    -Mapping to a network-share by means of @SUBST statement in batch file
    -The share contains a folder with several shared dll’s amoung which WebControls.dll used in the webproject

    Problem statement:
    When building in DEBUG-mode no errors occur. However, in RELEASE-mode I get the following error:

    When I move the WebControls.dll to a local folder, I get no error in either DEBUG- or RELEASE-mode.

    Can anyone please give some clue to the cause ???

  6. Dan says:

    Marten, it looks like you did not paste in the error that you get in release mode. Please post it here and I’ll see if I can help you out.

  7. Stephan says:

    You saved my life!

  8. bülent says:

    thanks for this solution. you saved my life, too.

  9. Luis Muñoz Costa Rica says:

    First of all, thank you very much, was amazing to find your solution, as a matter on fact I was working alone in the office, Friday 7:23 pm, suddenly, my virtual computer crashes… ok no problem, I restart my computer, then I continue compiling what I am suppose to finish in a couple of ours, and booms, this beautiful error appears. Ok, I go to Google, and search:

    Excepción de HRESULT: 0×80070057 + vs2008

    Only 2 webpages… well without any gram of faith I open the first one, and wow! The solution!

    Thanks!!!

  10. Thanks Dan, saved me alot of time.. great work..

  11. Saurabh says:

    Thanks for the reason and the solution
    However in my case,The folder “C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files” is empty
    in my case the reason is the security on the “Temporary ASP.NET Files” folder.

    Thanks Once again :)

  12. Jonathan K says:

    Thank you, thank you, thank you! I’ve been fighting my Windows 7 install, as it routinely crashes on me…recently it crashed smack in the middle of a compilation, and here’s ther answer to how to fix this pesky little error.

    Thanks!

Leave a Reply

More from Dan

Follow Me! Follow Me! Follow Me! Follow Me!
 
 
The Website Grade for www.abdinoor.com!