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

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

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

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


当前回答

谢谢你,亚历克斯,你的第二点帮我解决了这个问题。

除非你在Windows 7中以管理员身份运行visual studio,否则它将临时文件存储在本地,而不是C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP. net。网络文件。

参见以下博客文章:http://www.dotnetscraps.com/dotnetscraps/post/Location-of-Temporary-ASPNET-files-in-Vista-or-Windows-7.aspx

其他回答

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

明确的两个:

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

看看错误是否仍然发生

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

这可以在引用COM包装器dll时发生。在Visual Studio项目中,在References下,选择要引用的COM包装器dll,并确保它们具有以下属性值:"Embed Interop Types": False和"Specific Version": False。

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

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**.

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