I have tried to serialize all the child controls of the form using XamlServices.Save method. If i use the empty Datagridview which is working fine, but assign the datasource for datagridview which throws following exception,
System.MissingMethodException was unhandled HResult=-2146233069
Message=Constructor on type 'System.ComponentModel.ComponentConverter' not found. Source=mscorlib StackTrace: at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(Type type, Object[] args) at System.Xaml.Schema.SafeReflectionInvoker.CreateInstanceCritical(Type type, Object[] arguments) at System.Xaml.Schema.SafeReflectionInvoker.CreateInstance(Type type, Object[] arguments) at System.Xaml.Schema.XamlValueConverter 1.CreateInstance() at System.Xaml.Schema.XamlValueConverter 1.get_ConverterInstance() at System.Xaml.XamlObjectReader.TypeConverterExtensions.GetConverterInstance[TConverter](XamlValueConverter`1 converter) at System.Xaml.XamlObjectReader.SerializerContext.TryValueSerializeToString(ValueSerializer valueSerializer, TypeConverter propertyConverter, SerializerContext context, Object& value) at System.Xaml.XamlObjectReader.MemberMarkupInfo.GetPropertyValueInfoInternal(Object propertyValue, ValueSerializer propertyValueSerializer, TypeConverter propertyConverter, Boolean isXamlTemplate, XamlMember xamlProperty, SerializerContext context) at System.Xaml.XamlObjectReader.MemberMarkupInfo.GetPropertyValueInfo(Object propertyValue, XamlMember xamlProperty, SerializerContext context) at System.Xaml.XamlObjectReader.MemberMarkupInfo.ForReadWriteProperty(Object source, XamlMember xamlProperty, SerializerContext context) at System.Xaml.XamlObjectReader.MemberMarkupInfo.ForProperty(Object source, XamlMember property, SerializerContext context) at System.Xaml.XamlObjectReader.ObjectMarkupInfo.AddRecordMembers(Object value, SerializerContext context, ParameterInfo[] methodParameters, XamlType xamlType) at System.Xaml.XamlObjectReader.ObjectMarkupInfo.AddRecordMembers(Object value, SerializerContext context, TypeConverter converter) at System.Xaml.XamlObjectReader.ObjectMarkupInfo.ForObjectInternal(Object value, SerializerContext context, TypeConverter converter) at System.Xaml.XamlObjectReader.ObjectMarkupInfo.ForObject(Object value,at System.Threading.ThreadHelper.ThreadStart() InnerException:
Code
private void DemonstrateTheSerializationException()
{
// let's serialize this form to a file
var sFullPathFileName = "test.xml";
using (TextWriter writer = File.CreateText(sFullPathFileName))
{
XamlServices.Save(writer, this);
}
}
Am i use this method for serialization or am i missed anything here?
Thanks in advance,