我在桌面 WPF 应用程序中使用 Catel 框架,当我尝试将模型保存到文件时,我收到以下错误。
Type 'GeoChemicalFuncsCS.Core.Models.BoilingModel' with data contract name 'BoilingModel:http://schemas.datacontract.org/2004/07/GeoChemicalFuncsCS.Core.Models' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
我尝试将 KnownType 和 ServiceKnownType 标签添加到模型中,但我得到:
KnownType could not be found.
或者
ServiceKnownType could not be found.
而且我还尝试了在 ViewModel 中预热 SerializationFactory:
var typesToWarmup = new Type[] { typeof(BoilingModel) };
SerializationFactory.GetXmlSerializer().Warmup(typesToWarmup);
但没有任何改变。
有人有什么建议吗?此时我能做什么?
谢谢索尔·伊达尔戈。