[英]Object cannot be stored in an array of this type. issue in MVC c#
I am facing below issue on production application and not able to found any specific location or code as a cause of the error can anyone having any idea then please suggest a solution.我在生产应用程序中面临以下问题,并且无法找到任何特定位置或代码作为错误的原因,任何人都可以有任何想法然后请提出解决方案。
message="Object cannot be stored in an array of this type."
source="mscorlib"
detail="System.InvalidCastException: Object cannot be stored in an array of this type.

at System.Array.InternalSetValue(Void* target, Object value)

at System.Array.SetValue(Object value, Int32[] indices)

at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)

at System.Runtime.Serialization.ObjectManager.DoNewlyRegisteredObjectFixups(ObjectHolder holder)

at System.Runtime.Serialization.ObjectManager.RegisterObject(Object obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj, MemberInfo member, Int32[] arrayIndex)

at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject(Object obj, ParseRecord pr, ParseRecord objectPr, Boolean bIsString)

at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObjectEnd(ParseRecord pr)

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.Web.Util.AltSerialization.ReadValueFromStream(BinaryReader reader)

at System.Web.SessionState.SessionStateItemCollection.ReadValueFromStreamWithAssert()

at System.Web.SessionState.SessionStateItemCollection.DeserializeItem(String name, Boolean check)

at System.Web.SessionState.SessionStateItemCollection.get_Item(String name)

at System.Web.HttpSessionStateWrapper.get_Item(String name)

at System.Web.Mvc.SessionStateTempDataProvider.LoadTempData(ControllerContext controllerContext)

at System.Web.Mvc.TempDataDictionary.Load(ControllerContext controllerContext, ITempDataProvider tempDataProvider)

at System.Web.Mvc.Controller.PossiblyLoadTempData()

at System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state)

at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)

at System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)

at System.Web.Mvc.MvcHandler.<>c.<BeginProcessRequest>b__20_0(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState)

at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)

at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)

at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)

at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)" user="extranet\0031O00003QP1nTQAT"
time="2020-06-10T13:54:03.7681729Z">
I know its late, but I am curious if there was any development on this.我知道为时已晚,但我很好奇这方面是否有任何进展。
The "System.Web.Mvc.TempDataDictionary.Load" in the error definitely gives the clue that, this is something do with data stored in TempData.错误中的“System.Web.Mvc.TempDataDictionary.Load”肯定给出了线索,这与存储在 TempData 中的数据有关。 I also experienced the problem, but I could not exactly identify what data created the problem, because the code was abusing temp data a lot.
我也遇到了这个问题,但我无法准确确定是什么数据造成了问题,因为代码大量滥用临时数据。 Good news is that, I removed the code that uses TempData to store complex types.
好消息是,我删除了使用 TempData 存储复杂类型的代码。 Its been 30 days and the exception is not happening again.
已经 30 天了,异常不再发生。 Voila..!
瞧..!
https://github.com/dotnet/runtime/issues/28159 https://github.com/dotnet/runtime/issues/28159
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.