The following exception does not identify which type / member it's referring to, forcing the user to either debug and forage through System.TypedReference.MakeTypedReference or to manually walk the object graph in search of the offending type.
System.ArgumentException : Field in TypedReferences cannot be static or init only.
at System.TypedReference.MakeTypedReference(Object target, FieldInfo[] flds)
at System.Runtime.Serialization.ObjectManager.DoValueTypeFixup(FieldInfo memberToFix, ObjectHolder holder, Object value)
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.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
Seems like a good idea if it is practical. I imagine there are many other exception paths.
@danmosemsft maybe adding argument Name to this and in other place on this class, for these specific cases.
@MarcoRossignoli that makes sense where they are ArgumentExceptions like this one. Other cases if any would need it manually added to the message. Would you like to have a go at a PR at least for this case?
@danmosemsft ok i'll work on it! Feel free to assign to me!
@cdmihai if you find other such cases (different callstacks) please reopen or create a new issue so we can make a similar fix.
Most helpful comment
@cdmihai if you find other such cases (different callstacks) please reopen or create a new issue so we can make a similar fix.