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

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

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

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


当前回答

我在IIS上运行的“Chocolatey服务器(简单)”也有同样的问题,必须执行以下步骤

Clean the "C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files" as recommended Uninstall the "Chocolatey Server (Simple)" application via choco Remove the directory "C:\tools\chocolatey.server" from the chocolatey package directory. Important, because otherwise Web.config is holding old dependencies which leads to the error. A simple re-installation will not update an existing Web.config (as it was in my case). Restart IIS and config Chocolatey Server as recommended by the authors. The chocolatey server page should now be visible without any errors.

其他回答

这取决于您是否运行X64,您可能需要清理更多的位置。仅仅清理我的用户目录是不够的。

% % \ TEMP临时ASP。网络文件 C:\Windows\ Microsoft.NET \ Framework \ v2.0.50727 \临时ASP。网络文件 C:\Windows\ Microsoft.NET \ Framework \ v4.0.30319 \临时ASP。网络文件 C:\Windows\ Microsoft.NET \ Framework64 \ v2.0.50727 \临时ASP。网络文件 C:\Windows\ Microsoft.NET \ Framework64 \ v4.0.30319 \临时ASP。网络文件

如果你安装了其他版本的框架,这个列表将会增加。

看起来像是引用了一个损坏的程序集。

明确的两个:

项目的\bin文件夹 临时文件夹(应该是C:\Users\your_username\AppData\Local\ temp \Temporary ASP。windows 7中的NET文件

看看错误是否仍然发生

我让微软Office的Siemens Teamcenter 10客户端用户得到关于不同DLL的相同错误。其他答案都没用。解决方案是删除文件夹

C:\Users\%username%\AppData\Local\assembly\

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

谢谢

我有类似的问题,而打开Nuget包管理器, 我删除了所有的临时文件和建立项目,它工作得很好。