2017-09-27 28 views
0

我有一個Azure網絡應用程序.NET(4.6.1)/c#/MVC5/EF/Newtonsoft.JSON(6.0.4),它可以正常運行一個星期,然後突然出現500個錯誤,並且變得對每個人都無法使用。重新啓動和/或回收站點使網站恢復生機。我正在努力尋找根本原因。我看到有一些線程表明應用程序池的不合理回收會導致此行爲。但是,在IIS中,該站點被配置爲永不回收(空閒超時= 0,並且回收計劃設置爲0)。有沒有人經歷過這個或有建議?任何想法什麼會導致c#/ .net/EF/MVC5網站上的間歇性500序列化錯誤?

下面是錯誤的空話:

{"Message":"An error has occurred.","ExceptionMessage":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.","ExceptionType":"System.InvalidOperationException","StackTrace":null,"InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Error getting value from 'IsCompleted' on 'Weaver.TruckScaleMgmt.Common.Models.TruckLoad'.","ExceptionType":"Newtonsoft.Json.JsonSerializationException","StackTrace":" at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at Weaver.TruckScaleMgmt.Common.Models.TruckLoad.<>c.b__71_0(TruckLoadQuality t) in C:\Users\wh741\Source\Repos\Scalehouse\Weaver.TruckScaleMgmt.Common\Models\TruckLoad.cs:line 223\r\n at System.Linq.Enumerable.WhereListIterator`1.MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Weaver.TruckScaleMgmt.Common.Models.TruckLoad.UpdateCompletedRequirements() in C:\Users\wh741\Source\Repos\Scalehouse\Weaver.TruckScaleMgmt.Common\Models\TruckLoad.cs:line 223\r\n at Weaver.TruckScaleMgmt.Common.Models.TruckLoad.get_IsCompleted() in C:\Users\wh741\Source\Repos\Scalehouse\Weaver.TruckScaleMgmt.Common\Models\TruckLoad.cs:line 335\r\n at GetIsCompleted(Object)\r\n at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)"}}}

。 。 。

更新:

我已經能夠重現該問題,並認爲它是一個布爾變量的序列化的問題。我還沒有確定,但我相信我知道根本原因。我剛纔發佈的代碼是不相關的根源....

UPDATE2:

確定。我已經解決了這個問題。在藍色月亮中發生的情況在linq查詢中的字段內留下空值。然而,我不知道的是,爲什麼這會讓應用程序無法適用於所有人。有一個例子讓應用程序假髮給大家.....

+0

那麼在'IsCompleted'和'UpdateCompletedRequirements()'中會發生什麼?你有一個NRE。 –

+0

它在下面的quality.where聲明上失敗。不過,我認爲這是一個症狀。它工作正常99%的時間。 – elletek

+0

您希望從控制器方法中獲得什麼類型的輸出?看來輸出沒有序列化爲json。那是錯誤 –

回答

1

我已經解決了這個問題。在藍色月亮中發生的情況在linq查詢中的字段內留下空值。然而,我不知道的是,爲什麼這會讓應用程序無法適用於所有人。有一個例子讓應用程序假髮給大家.....

相關問題