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

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.

Categorized: .NET

21 comments on “Fixing .NET error HRESULT: 0×80070057 (E_INVALIDARG)

  1. 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 ???

  2. 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.

  3. 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!!!

  4. 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 :)

  5. 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!