我得到以下错误,但仅在生产环境中。在本地开发环境中,应用程序运行时没有问题。
在我的应用程序中,我没有引用Json版本6.0.0
更新:通过将(VS2015)发布到本地驱动器并在本地运行approot/web.cmd,我可以在本地复制此错误。所以也许这个问题出现在了发布中.
问:我如何解决这个问题?
System.IO.FileNotFoundException:无法加载文件或程序集“Newtonsoft.Json、Version=6.0.0.0、Culture=neutral、PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。系统找不到指定的文件。文件名:'Newtonsoft.Json,Version=6.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed‘ (在Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream流)在Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationBuilder.Add(IConfigurationProvider provider)在Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder configurationBuilder,String path (布尔可选)在Microsoft.AspNet.Hosting.WebApplication.Run(Type startupType,( Microsoft.AspNet.Server.Kestrel.Program.Main(String[] args中的String[] args) --从抛出异常的以前位置开始的堆栈跟踪的结束--在Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly程序集的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly程序集中,String[] args,( Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.b__0() at System.ThreadingT.asks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute() file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/ ===预绑定状态信息===日志: DisplayName = Newtonsoft.Json、Version=6.0.0.0、Culture=neutral、PublicKeyToken=30ad4fe6b2a6aeed (完全指定)日志: Appbase ====:初始PrivatePath = NULL调用程序集:(未知)。===日志:这个绑定是在默认加载上下文中启动的。日志:没有找到应用程序配置文件。日志:使用主机配置文件: LOG:使用来自C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.的计算机配置文件日志:策略后引用: Newtonsoft.Json、Version=6.0.0.0、Culture=neutral、PublicKeyToken=30ad4fe6b2a6aeed日志:融合托管.检查主机有关此程序集的信息。日志:尝试使用程序集newtonsoft.json、version=6.0.0.0、culture=neutral、publickeytoken=30ad4fe6b2a6aeed、processorarchitecture=x86的主机程序集存储。日志:尝试使用程序集newtonsoft.json、version=6.0.0.0、culture=neutral、publickeytoken=30ad4fe6b2a6aeed、processorarchitecture=msil的主机程序集存储。日志:尝试使用程序集newtonsoft.json、version=6.0.0.0、culture=neutral、publickeytoken=30ad4fe6b2a6aeed的主机程序集存储。主机程序集存储不包含此程序集。日志:尝试下载新的URL file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json.DLL.日志:尝试下载新的file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json/Newtonsoft.Json.DLL.日志:尝试下载新的file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json/Newtonsoft.Json.DLL.文件:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json.EXE.日志:尝试下载新的file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json/Newtonsoft.Json.EXE.
发布于 2016-07-08 08:14:22
新的Newtonsoft.Json 9.0.1已经发布了ASP.NET核心支持。
发布于 2016-03-13 06:20:34
更新:我认为这与这里描述的一个bug (https://github.com/aspnet/Tooling/issues/45)有关,它与在解决方案中创建项目的顺序有关。在本例中,我从一个.NET 4.5.1类库开始,然后添加了ASP.NET Core1.0 WebAPI项目。出于某种原因,每当我添加类库时,Json.NET都会被添加到项目中,但版本号为1.0。
--我的解决方案是通过表单scratch启动解决方案。这次我从WebAPI项目开始,然后添加到类库中,然后在WebAPI项目中引用类库,现在它显示了Json.NET 8.0.2.
我希望微软能解决这个问题,因为你应该可以在现有的解决方案中添加一个ASP.NET核心应用程序,而不会有任何问题,不幸的是,目前情况并非如此,
https://stackoverflow.com/questions/35953717
复制