最近我在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。网络文件\

其他回答

我遇到了同样的错误,因为应用程序没有在C:\Program Files (x86)\Reference程序集\Microsoft\框架\中找到依赖框架。NETFramework \文件夹。我只是修复了我的Visual studio,在上面的位置添加了所需的框架,它工作得很好。

我在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.

删除这些文件夹中的所有文件。

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

清除此文件夹(仅限windows x64)

C:\Windows\ Microsoft.NET \ Framework \ v4.0.30319 \临时ASP。网络文件

在我的案例中,在我的项目属性中更改IISExpress端口号解决了这个问题。