You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// DataContractResolver to be used by the DataContractSerializerclassMyDataContractResolver:DataContractResolver{privateXmlDictionarydictionary=new XmlDictionary();<--Here **********
...// Used at serialization// Maps any Type to a new xsi:type representationpublicoverrideboolTryResolveType(Typetype,TypedeclaredType,DataContractResolverknownTypeResolver,outXmlDictionaryStringtypeName,outXmlDictionaryStringtypeNamespace){if(!knownTypeResolver.TryResolveType(type, declaredType,null,out typeName,out typeNamespace)){XmlDictionarydictionary=new XmlDictionary();<-- And here **********typeName= dictionary.Add(type.FullName);typeNamespace= dictionary.Add(type.Assembly.FullName);}returntrue;}}
Local variable dictionary or field dictionary?
In the
MyDataContractResolver
class in https://github.com/dotnet/samples/blob/main/framework/wcf/Basic/Contract/Data/NetDCSasDCSwithDCR/CS/DCSwithDCR/DCSwithDCR.cs, there is a fielddictionary
and there is also a local variabledictionary
in the methodTryResolveType()
. So the fielddictionary
is never used. It seems to me that the original intent was to use the fielddictionary
and the local variabledictionary
shouldn't have been there.Note that the same code is also on this page - https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/datacontractserializer-datacontractresolver-netdatacontractserializer.
Target framework
Check the .NET target framework(s) being used, and include the version number(s).
The text was updated successfully, but these errors were encountered: