noo*_*Dev 203 json json.net .net-assembly
搜索后我尝试过的事情:
在Web.Config中对旧版本进行了绑定:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.1.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)编辑我的.csproj文件以确保只有一个Newtonsoft引用
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</Reference>
Run Code Online (Sandbox Code Playgroud)在我的计算机上搜索每个Newtonsoft.Json.dll并删除每个非6.0.1版本并删除我的临时文件夹的内容
在nuget manager控制台中修复/重新安装软件包
它成功构建,但在访问网站时出错.
编辑
好吧,所以然后我尝试重新安装像每个nuget包,它似乎已经添加了4.5版本的newtonsoft.json.dll,但我得到相同的错误.我的项目的目标freamework是.NET 4.5.1,这是我现在得到的堆栈跟踪:
'/'应用程序中的服务器错误.
无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:System.IO.FileLoadException:无法加载文件或程序集"Newtonsoft.Json"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
来源错误:
在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
程序集加载跟踪:以下信息有助于确定无法加载程序集"Newtonsoft.Json"的原因.
===预绑定状态信息===日志:DisplayName = Newtonsoft.Json(部分)WRN:为程序集提供了部分绑定信息:WRN:程序集名称:Newtonsoft.Json | 域ID:2 WRN:仅提供部分程序集显示名称时发生部分绑定.警告:这可能导致装订器装入错误的装配.警告:建议为程序集提供完全指定的文本标识,即WRN:由简单名称,版本,区域性和公钥标记组成.警告:有关此问题的更多信息和常见解决方案,请参阅白皮书http://go.microsoft.com/fwlink/?LinkId=109270.日志:Appbase = file:/// c:/ users/user/documents/visual studio 2013/Projects/foo/bar/LOG:Initial PrivatePath = c:\ users\user\documents\visual studio 2013\Projects\foo\bar\bin调用程序集:(未知).===日志:此绑定在默认加载上下文中启动.日志:使用应用程序配置文件:c:\ users\user\documents\visual studio 2013\Projects\foo\bar\web.config日志:使用主机配置文件:C:\ Users\user\Documents\IISExpress\config\aspnet .config日志:使用C:\ Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config中的计算机配置文件.日志:此时策略未应用于引用(私有,自定义,部分或基于位置的程序集绑定).日志:尝试下载新的URL文件:/// C:/ Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json.DLL.日志:尝试下载新的URL文件:/// C:/ Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json/Newtonsoft.Json.DLL.日志:尝试下载新的URL文件:/// c:/ users/user/documents/visual studio 2013/Projects/foo/bar/bin/Newtonsoft.Json.DLL.日志:使用应用程序配置文件:c:\ users\user\documents\visual studio 2013\Projects\foo\bar\web.config日志:使用主机配置文件:C:\ Users\user\Documents\IISExpress\config\aspnet .config日志:使用C:\ Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config中的计算机配置文件.日志:在应用程序配置文件中找到重定向:4.5.0.0重定向到6.0.1.0.日志:政策后参考:Newtonsoft.Json,Version = 6.0.1.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed日志:尝试下载新的URL文件:/// C:/ Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json.DLL.日志:尝试下载新的URL文件:/// C:/ Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json/Newtonsoft.Json.DLL.日志:尝试下载新的URL文件:/// c:/ users/user/documents/visual studio 2013/Projects/foo/bar/bin/Newtonsoft.Json.DLL.警告:比较程序集名称导致不匹配:主要版本错误:无法完成程序集的设置(hr = 0x80131040).探测终止.
堆栈跟踪:
[FileLoadException:无法加载文件或程序集'Newtonsoft.Json'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)]
[FileLoadException:无法加载文件或程序集'Newtonsoft.Json,Version = 6.0.1.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+0 System.Reflection.RuntimeAssembly .nLoad(的AssemblyName文件名,字符串的代码库,证据assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr的pPrivHostBinder,布尔throwOnFileNotFound,布尔forIntrospection,布尔suppressSecurityChecks)34 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName assemblyRef,证据assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMa rk,IntPtr pPrivHostBinder,Boolean forIntrospection)+77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMark,Boolean forIntrospection)+16 System.Reflection.Assembly.Load(String assemblyString)+28 System.Web.Configuration .CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+38
[ConfigurationErrorsException:无法加载文件或程序集'Newtonsoft.Json,Version = 6.0.1.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+752 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+ 218 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo) ai)+130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()+91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath,Boolean&isRefAssemblyLoaded)+285 System.Web.Compilation.BuildManager.ExecutePreAppStart()+153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException)+516
[HttpException(0x80004005):无法加载文件或程序集'Newtonsoft.Json,Version = 6.0.1.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+9913572 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context)+254
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.18408
use*_*388 261
为了解决这个问题,我通过运行以下命令并检查结果来确保我的所有项目都使用相同的版本:
update-package Newtonsoft.Json -reinstall
Run Code Online (Sandbox Code Playgroud)
最后,我从web.config中删除了以下内容:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
如果要确保所有Newtonsoft.Json软件包都是相同的版本,可以像下面这样指定版本:
update-package Newtonsoft.Json -version 6.0.0 -reinstall
Run Code Online (Sandbox Code Playgroud)
Cra*_*igV 80
我正在使用Newtonsoft.Json v6.0.3,但这是我在Web.config文件中必须做的事情:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
请注意,即使我使用6.0.3,我也不得不投入使用 newVersion="6.0.0.0"
在我的packages.config文件中,我有:
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
Run Code Online (Sandbox Code Playgroud)
小智 59
在确保我的计算机在所有位置都具有相同版本并且我的项目都指向相同的参考路径之后,我尝试了以下操作.我还确保旧版本的绑定是他们的,并且绑定到我当前版本的dll.
我在一个有严格框架的环境中工作,框架团队经常用不同的dll来破坏版本控制.
我如何解决这个问题是在visual studio(2013)中运行包管理器控制台.从那里我运行以下命令:
update-package Newtonsoft.Json -reinstall
Run Code Online (Sandbox Code Playgroud)
其次是
update-package Newtonsoft.Json
Run Code Online (Sandbox Code Playgroud)
这经历并更新了我的所有配置文件和相关的项目文件.强迫它们全部使用相同版本的dll.这是最初版本4.5再次更新以获得最新版本.
小智 25
我有相同的错误消息,就像你提到的那样,这是由于引用了不同版本的Newtonsoft.Json.dll.
我的MVC解决方案中的一些项目使用NuGet包来实现该DLL的第4版.
然后我添加了一个NuGet包(对于我的案例中的Salesforce),它带来了Newtonsoft.Json版本6,并将其作为对其中一个项目的依赖.这就是我引发问题的原因.
为了清理,我使用NuGet包管理器中的更新部分来解决方案(在"工具"菜单或解决方案右键单击)中更新整个解决方案中的Json.Net包,因此它对于所有项目都是相同的版本.
之后我只检查了App Config文件,以确保任何绑定重定向行都转到我选择的版本,如下所示.
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
Run Code Online (Sandbox Code Playgroud)
noo*_*Dev 17
好的,我想我现在可以上班了.我删除了我的机器上的每个Newtonsoft.Json.dll,它不是我能找到的最新版本,确保我在NuGet中有最新版本,并构建它并确保它是bin文件夹中的最新版本,并且我在web.config和.csproj中留下了更改.现在我正在接受另一个错误,所以它必须正常工作..
经过几个小时的努力......我做了以下事情:
网页配置
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<!-- other assemblies... -->
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
输入正确的新版本和旧版本号的关键是打开项目的References
找到包转到其属性或单击alt + enter
你会发现一个部分Version
,在我的情况下12.0.0.0
,实际上是12.0.3
在使用 Manage NuGet 进行探索时。
所以你需要从参考属性中选择包的版本(在我的例子中
12.0.0.0
)
最后,clean
还有rebuild
项目(您可能想删除之前的bin
和obj
文件夹)。
您可能会遇到其他软件包依赖问题,我为所有人做了这些,并且它们奏效了。
通过在我的web.config上将此部分注释掉,解决了我的问题:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
但是,当然,您需要在程序包管理器控制台中执行以下操作,以确保已更新或版本正确:
update-package Newtonsoft.Json -reinstall
Run Code Online (Sandbox Code Playgroud)
就我而言,这只是一个问题:
Tools -> NuGet Package Manager -> Package Manager Settings -> Clear Cache
Run Code Online (Sandbox Code Playgroud)
该问题是在我重新映射 TFS 文件夹时引起的。
您可以通过在 web.config 文件中添加以下行来解决该问题。
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
335222 次 |
最近记录: |