问题描述
使用Visual Studio 2015将Web API应用程序部署到Azure之后,立即得到运行时错误"/应用程序中的服务器错误"
查看azure应用程序服务的日志文件eventlog.xml时,我发现以下错误详细信息:
无法加载文件或程序集"Newtonsoft.Json,版本= 6.0.0.0,区域性=中性,PublicKeyToken = 30ad4fe6b2a6aeed"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040)
在System.Net.Http.Formatting.BaseJsonMediaTypeFormatter..ctor()
在System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor()
在System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters()
在System.Web.Http.HttpConfiguration.DefaultFormatters(HttpConfiguration config)
在System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection路由)上
在System.Web.Http.GlobalConfiguration.& lt;& gt; c.& lt; CreateConfiguration& gt; b__11_0()
在System.Lazy`1.CreateValue()
在System.Lazy`1.LazyInitValue()
在System.Lazy`1.get_Value()
在photovoltax.WebApis.UnityWebApiActivator.Start()
在Web.config中,我们有:
< dependentAssembly>
< assemblyIdentity name ="Newtonsoft.Json";文化=中立" publicKeyToken ="30ad4fe6b2a6aeed"; />
< bindingRedirect oldVersion ="0.0.0.0-12.0.0.0&"; newVersion ="12.0.0.0&"; />
</dependentAssembly>
在packages.config中:
< package id ="Newtonsoft.Json";版本="12.0.1" targetFramework ="net46" />
在Visual Studio的引用"下,我们有对C:\ vs \ Packages \ Newtonsoft.Json.12.0.1 \ lib \ net45 \ Newtonsoft.Json.dll的引用.
即使在.csproj文件中,我们也没有引用"Newtonsoft.Json,Version = 6.0.0.0"
我已经将所有nuget软件包更新为最新版本.问题一直存在.
有什么事吗?
在哪里可以找到有关错误原因或程序集引用"Newtonsoft.Json,Version = 6.0.0.0"的更多详细信息?
Directly after deploying a Web API app to Azure using Visual Studio 2015 I get a Runtime Error "Server Error in '/' Application"
Looking into the log file eventlog.xml of the azure app service I found the following error details:
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters()
at System.Web.Http.HttpConfiguration.DefaultFormatters(HttpConfiguration config)
at System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes)
at System.Web.Http.GlobalConfiguration.<>c.<CreateConfiguration>b__11_0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at photovoltax.WebApis.UnityWebApiActivator.Start()
In Web.config we have:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
In packages.config:
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net46" />
In Visual Studio under References we have a reference to C:\vs\Packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll
Even in the .csproj file we have no reference to "Newtonsoft.Json, Version=6.0.0.0"
I have updated all nuget packages to the newest versions. The problems persits.
What can be wrong?
Where can I get more details about the reason of the error or the assembly referencing to "Newtonsoft.Json, Version=6.0.0.0"?
谢谢
彼得
推荐答案
这篇关于使用Visual Studio Professional部署Web API App后出现错误500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!