[英]ASP.NET Core 1.0 RC1-Update1, System.IO.FileNotFoundException: Could not load file or assembly > 'Newtonsoft.Json
I get the following error, but ONLY in the production environment . 我收到以下错误,但仅在生产环境中 。 Locally in the development environment, the application runs without issue.
在开发环境中本地运行该应用程序不会出现问题。
Nowhere in my app am I referencing Json Version 6.0.0 我的应用程序无处引用Json版本6.0.0
UPDATE: I can reproduce this error locally by PUBLISHING (VS2015) to local drive, and running approot/web.cmd locally. 更新:我可以通过在本地驱动器上发布(VS2015)并在本地运行approot / web.cmd来在本地重现此错误。 So maybe the issue is in the publish.
所以也许问题在发布中。
Question: How can I resolve this issue? 问题:如何解决此问题?
System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
System.IO.FileNotFoundException:无法加载文件或程序集“ Newtonsoft.Json,版本= 6.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed”或其依赖项之一。 The system cannot find the file specified.
该系统找不到指定的文件。 File name: 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
文件名:“ Newtonsoft.Json,版本= 6.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed”
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationBuilder.Add(IConfigurationProvider provider) at Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder configurationBuilder, String path, Boolean optional) at Microsoft.AspNet.Hosting.WebApplication.Run(Type startupType, String[] args) at Microsoft.AspNet.Server.Kestrel.Program.Main(String[] args) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider) at Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.b__0() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute()在Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load()处的Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load()处的Microsoft.Extensions.Configuration.ConfigurationBuilder.Add(IConfigurationProvider提供者)在Microsoft.Extensions.Configuration .JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder configurationBuilder,字符串路径,布尔值可选)在Microsoft.AspNet.Hosting.WebApplication.Run(类型startupType,String [] args)在Microsoft.AspNet.Server.Kestrel.Program.Main(String [] args )---从先前引发异常的位置开始的堆栈跟踪---在Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly,String [] args处的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()处,IServiceProvider serviceProvider)在Microsoft.Dnx.ApplicationHost.Program。<> c__DisplayClass3_0.b__0()在System.Threading.Tasks.Task`1.InnerInvoke()在System.Threading.Tasks.Task.Execute()
=== Pre-bind state information === LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed (Fully-specified) LOG: Appbase = file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown).
===预绑定状态信息===日志:DisplayName = Newtonsoft.Json,版本= 6.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed(完全指定)日志:Appbase = file:/// C:/ inetpub /_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/ LOG:初始PrivatePath = NULL调用程序集:(未知)。 === LOG: This bind starts in default load context.
=== LOG:此绑定在默认加载上下文中启动。 LOG: No application configuration file found.
日志:找不到应用程序配置文件。 LOG: Using host configuration file: LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config.
日志:使用主机配置文件:日志:使用来自C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ config \\ machine.config的计算机配置文件。 LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed LOG: Fusion is hosted.
日志:政策后参考:Newtonsoft.Json,版本= 6.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed日志:托管Fusion。 Check host about this assembly.
检查主机有关此程序集。 LOG: Try host assembly store with assembly newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed, processorarchitecture=x86.
日志:尝试使用程序集newtonsoft.json,版本= 6.0.0.0,文化=中性,publickeytoken = 30ad4fe6b2a6ed,处理器体系结构= x86来托管主机程序集存储。 LOG: Try host assembly store with assembly newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed, processorarchitecture=msil.
日志:尝试使用程序集newtonsoft.json,版本= 6.0.0.0,区域性=中性,publickeytoken = 30ad4fe6b2a6ed,处理器体系结构= msil,进行主机程序集存储。 LOG: Try host assembly store with assembly newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed.
日志:尝试使用程序集newtonsoft.json,版本= 6.0.0.0,区域性=中性,publickeytoken = 30ad4fe6b2a6aeed进行主机程序集存储。 WRN: Host assembly store does not contain this assembly.
WRN:主机程序集存储不包含此程序集。 LOG: Attempting download of new URL file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json.DLL.
日志:尝试下载新的URL文件:/// C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json.DLL。 LOG: Attempting download of new URL file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json/Newtonsoft.Json.DLL.
日志:尝试下载新的URL文件:/// C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json/Newtonsoft.Json.DLL 。 LOG: Attempting download of new URL file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json.EXE.
日志:尝试下载新的URL文件:/// C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json.EXE。 LOG: Attempting download of new URL file:///C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json/Newtonsoft.Json.EXE.
日志:尝试下载新的URL文件:/// C:/inetpub/_ALPHA/approot/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/Newtonsoft.Json/Newtonsoft.Json.EXE 。
带有ASP.NET Core支持的新Newtonsoft.Json 9.0.1已发布。
Update: I think this is related to a bug described here ( https://github.com/aspnet/Tooling/issues/45 ) which has to do with the order in which projects are created inside the solution. 更新:我认为这与此处描述的错误( https://github.com/aspnet/Tooling/issues/45 )有关,该错误与在解决方案中创建项目的顺序有关。 In this case, I started with a .NET 4.5.1 class library, then added the ASP.NET Core 1.0 WebAPI project.
在这种情况下,我从.NET 4.5.1类库开始,然后添加了ASP.NET Core 1.0 WebAPI项目。 For some reason, whenever I added my class library, Json.NET would get added to the project, but with a version number of 1.0.
出于某种原因,每当我添加我的类库时,Json.NET都会被添加到项目中,但是版本号为1.0。
My solution was to start the solution over form scratch. 我的解决方案是从头开始解决方案。 This time I started with the WebAPI project, then added in the class library, then referenced the class library within the WebAPI project, and it now shows Json.NET 8.0.2.
这次,我从WebAPI项目开始,然后添加到类库中,然后在WebAPI项目中引用该类库,现在它显示了Json.NET 8.0.2。
I hope Microsoft gets this bug fixed, as you should be able to added a ASP.NET Core app to an existing solution without any issues, unfortunately this is not currently the case, 我希望Microsoft能够修复此错误,因为您应该能够将ASP.NET Core应用添加到现有解决方案中而没有任何问题,不幸的是,当前情况并非如此,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.