Could not load file or assembly ... The parameter is incorrect

Liker777 picture Liker777 · Nov 25, 2011 · Viewed 117.1k times · Source

Recently I met the following exception at C# solution:

Error 2 Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b9a188c8922137c6' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

This does not depend either on my code or on the name of assembly (like Newtonsoft.Json in this case).

When I delete this dll from the solution the compiler tells about another in the same exception. So I suppose something shoud be turned off/on at my PC :)

Answer

Alex picture Alex · Nov 25, 2011

Looks like a corrupted assembly being referenced.

Clear both:

  1. the \bin folder of your project

  2. the temp folder (should be C:\Users\your_username\AppData\Local\Temp\Temporary ASP.NET Files in windows 7)

and see if the error still happens