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;
}
}