How to fix “HRESULT: 0x80070057 (E_INVALIDARG)”

When I was compiling a site with VS2010 the power went down and afterwards it failed to run even after performing the classic problem-solving combo:

  • solution clean up and
  • temporary files removal:
    • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\ or
    • C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ (depending on the framework version).

The error message was:
Could not load file or assembly ‘[assembly name]’ or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

The solution is fast and simple, just clean the temporary folder used by Visual Studio:
C:\Users\[CurrentUserAccount]\AppData\Local\Temp\Temporary ASP.NET Files\

ASP.NET view state decoders

Lately I had to optimize some pages so I needed to see what’s inside that ugly, evil view state. Fortunately there’s a bunch of free tools already available, so I’ll just make a short list of the ones I liked the most.

  1. – Online view state decoder
  2. The already famous ViewState Decoder by Fritz Onion from Pluralsight
  3. ASP.NET ViewState Helper – from Binary Fortress Software – this one is a bit slow but has a great feature, it shows the percent of the views state in the total page size.
  4. ASP.NET ViewState Helper (Fiddler) – from Binary Fortress Software – just a simple but useful extension for Fiddler2.
  5. ViewState Decoder Add-On for Firefox

Another great but also expensive tool is Burp Proxy. It can be used to intercept and change anything that’s sent/received via HTTP not only the view state and this makes it a handy security test tool.

Before trying to use any of these tools, check your web.config and make sure that the view state is not encrypted and/or chunked.

<?xml version="1.0"?>
        <pages viewStateEncryptionMode="Never"> 
        <!-- When testing make sure to remove view state chunking (attribute
             from the pages tag) -->

VS2008 debugger fails to attach

Today, when trying to debug a 3.5 web site using VS2008, I noticed that it failed to attach to the process although the site opened correctly in the browser. In fact, the debugger starts but immediately fails without any error message.

Then, when trying to manually attach it, I’ve got a strange error in the output window: “The thread ‘Win32 Thread’ (0x1e04) has exited with code 0 (0x0).”

After a bit of !??!!? it turned out that the location tag in the web.config was the source of this annoying problem so temporarily removing it got things back to normal.

<!-- I removed the location tag because VS2008 fails to start de debugger
  <location path="." inheritInChildApplications="false" >

PS: This doesn’t happen in VS2010.