Newtonsoft.Json.JsonReaderException,无法找到程序集' Newtonsoft.Json ......'

时间:2015-04-08 12:44:20

标签: c# asp.net json.net

我有一个SMS类,它使用Newtonsoft.Json方法来解析json。 此类由一个方法(RunSmsService)调用,该方法每30秒执行一次,并基于过期的缓存系统。 RunSmsService方法首先由Application_Start(Global.asax.cs)

启动

几乎每次调用SMS类时,都会抛出以下异常,一段时间后应用程序池崩溃。

Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Newtonsoft.Json.JsonReaderException
Stack:
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__5(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

An unhandled exception occurred and the process was terminated.

Application ID: DefaultDomain

Process ID: 9232

Exception: System.Runtime.Serialization.SerializationException

Message: Unable to find assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.

StackTrace:    at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
   at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.AppDomain.Deserialize(Byte[] blob)
   at System.AppDomain.UnmarshalObject(Byte[] blob)

我抬头查找了与#34相关的帖子;无法找到装配&#39; Newtonsoft.Json,...&#34;错误,但没有帮助!

任何人都知道解决方案吗?

1 个答案:

答案 0 :(得分:0)

我发现了什么问题 在我的SMS课程中,我正在使用HttpClient读取一个url,它应该返回一个json。 在某些情况下,它返回一个空字符串,因为我正在使用JObject.Parse解析字符串,所以会抛出异常。

当抛出JSON解析中的异常(在Newtonsoft.Json中)时,几乎会导致此错误:Unable to find assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

我错误的是不要在try / catch中包围那部分代码 感谢