XamlWriter fails to serialize objects in WinForms app
Posted
by Eddie
on Stack Overflow
See other posts from Stack Overflow
or by Eddie
Published on 2009-04-16T16:44:07Z
Indexed on
2010/04/19
4:03 UTC
Read the original article
Hit count: 471
Apparently XamlWriter doesn't works correctly in a WinForms application.
XamlWriter uses MarkupWriter.GetMarkupObjectFor(object obj). I suppose that there's a problem to determine the full list of properties to serialize.
var ar = new AssemblyReference(AppDomain.CurrentDomain.GetAssemblies().First()); var str = XamlWriter.Save(ar);
Running an ASP.NET or WPF application I got this result:
<AssemblyReference AssemblyName="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
HintPath="file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll"
SpecificVersion="False" xmlns="clr-namespace:Ivolutia.TypeModel;assembly=ivoTypeModel" />
But running the same code in a WinForms application I got this:
<AssemblyReference xmlns="clr-namespace:Ivolutia.TypeModel;assembly=ivoTypeModel" />
this is the class definition:
public class AssemblyReference : DependencyObject
{
public string AssemblyName { get; set; }
public string HintPath { get; set; }
public bool SpecificVersion { get; set; }
public AssemblyReference() { }
public AssemblyReference(Assembly assembly)
{
AssemblyName = assembly.FullName;
HintPath = assembly.CodeBase;
}
public override string ToString()
{
return AssemblyName;
}
}
© Stack Overflow or respective owner