最近我在c#解决方案中遇到了以下异常:

错误2无法加载文件或程序集'Newtonsoft。Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b9a188c8922137c6'或 它的依赖项之一。参数不正确。(例外 HRESULT: 0x80070057 (E_INVALIDARG))

这既不取决于我的代码,也不取决于程序集的名称(如Newtonsoft)。Json)。

当我从解决方案中删除这个dll时,编译器会在相同的异常中告诉另一个dll。所以我想我的电脑应该关闭/打开一些东西:)


当前回答

清除C:\Windows\Microsoft.NET\Framework\v2.0.50727\临时ASP。NET文件对我有用。考虑将删除过程自动化,以避免将来出现这种问题。

其他回答

我必须清除

C: / Windows / Microsoft.NET/Framework/v4.0.30319/Temporary ASP。网络文件

直到那时,问题才得到解决。

要知道清除什么确定-添加以下注册表项:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\EnableLog (DWord set to 1).

然后您将看到如下所示的输出。这将告诉你asp.net试图加载dll的位置。清除该目录。

LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\app\AtlasAdvisor\web\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL **file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/3c8629f7/dfa387b6/Avanade.ViddlerNet.DLL.**
LOG: Attempting download of new URL **file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/3c8629f7/dfa387b6/Avanade.ViddlerNet/Avanade.ViddlerNet.DLL**.

从源代码控制处获得一组新的二进制文件会有所帮助。

谢谢

您可以清除、构建或重新构建应用程序,也可以简单地删除临时ASP。C:\Users\YOUR USERNAME\AppData\Local\Temp

这就像魔法一样。在我的情况下,我有一个程序集绑定问题说无法加载文件bla bla bla

你也可以看到解决方案2为http://www.codeproject.com/Articles/663453/Understanding-Clean-Build-and-Rebuild-in-Visual-St

清除临时框架文件为您的项目:-

C:\WINDOWS\ Microsoft.NET \ Framework \ v2.0.50727 \临时ASP。网络文件\