all groups > dotnet windows forms designtime > september 2005 >
You're in the

dotnet windows forms designtime

group:

XML Serialization in the BasicDesignerLoader Class


XML Serialization in the BasicDesignerLoader Class David Whitchurch-Bennett
9/22/2005 12:10:02 PM
dotnet windows forms designtime: Firstly, I am writing my project in VB.NET in VS2005.

I am working on a custom forms designer, and am trying to save and load the
layout to an XML file.

I have overriden the PerformFlush method of the base class
BasicDesignerLoader, and want to serialize to XML. Problem is, I can't create
the XMLSerializer object because it can't perform relection on the Form type.
How can I get this serializer to work with the BasicDesignerLoader, and is
this possible at all?

Thanks,

RE: XML Serialization in the BasicDesignerLoader Class David Whitchurch-Bennett
9/23/2005 3:04:08 AM
Thanks for that information. It is very difficult for me to translate the
code into VB, but I think I see how it is done. I am also trying to learn to
deserialize CodeDOM statements into the designer, and if I can get the VB
back to CodeDom, then that will be the prefered method. Failing that, I will
look at this again, but it seems way to compicated if I can use the CodeDom.

Thanks for the pointer though, and it will certainly help!

[quoted text, click to view]
RE: XML Serialization in the BasicDesignerLoader Class v-jetan NO[at]SPAM online.microsoft.com (
9/23/2005 7:49:41 AM
Hi David,

Thanks for your post.

Yes, this is because Form class did not have SerializableAttribute.
Actually, we have to do the Xml serialization ourselves. Microsoft has
released a KB to demonstrate a sample DesignerHost, please refer to the KB
below:
"INFO: Code Sample That Demonstrates How to Create a Custom Form Designer
by Using Visual C# .NET"
http://support.microsoft.com/default.aspx?scid=kb;en-us;813808

In this sample, the serialization code is located in SampleDesignerHost.cs
file. The key xml serialization code is SampleDesignerHost.Flush method. We
can see that it uses XmlDocument class and other xml classes to serialize
the controls/components itself. Also, it also provided another way of
serialization using Code DOM to serialize the controls/components as
C#/VB.net code file.

I think you may get a lot of useful information from this sample.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
AddThis Social Bookmark Button