473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

[XmlInclude(typeof(System.Drawing.Font))]

Hello,
I am learning how to use the XmlSerializer. I have a class that has a
member of type
System.Drawing.Font such as:

[XmlInclude(typeof(System.Drawing.Font))]
[XmlRoot("ProModelChartFX")]
public class MyClass
{
Font font;
public Font Font
{
get{return font;}
set{font = value;}
}
public MyClass(){}
}

Whenever I try to:
XmlSerializer ser = new XmlSerializer(typeof(MyClass));

an exception is thrown of "Additional information: There was an error
reflecting type MyClass.MyClass."

Does the Font type support serialization? Do I have create my own special
font object and include it? Any advice or links would much appreciated.

Thanks in advanced!
Dan H.
Nov 12 '05 #1
1 2029
With some help from this link:
http://weblogs.asp.net/cschittko/articles/33045.aspx

I was able to figure out the issue which is:

--------- Exception Data ---------
Message: System.Drawing.Font cannot be serialized because it does not have a
default public constructor.
Exception Type: System.InvalidOperationException
Source: System.Xml
This seems like it would be a common problem of XmlSerializing .net
framework classes that do not have a default public constructor. Are there
any good articles discussing recommended practices of how to handle?

Given this, would you recommend wrapping the Font into a custom class?

Thanks again,
Dan H.
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin Van Patten | last post by:
Hello, I am having trouble converting a LOGFONT structure to a System.Drawing.Font object. I'm calling SystemParametersInfo to get the LOGFONT lfntSMCaptionFont from a NONCLIENTMETRICS...
0
by: hesing Qiang | last post by:
In Print Process,I use the code,but it is not run correctly On WINDOWS 98 . I didn't know why ...? this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular,...
3
by: Barry Anderberg | last post by:
I'm using the .NET Memory Profiler by Sci Tech and I wrote a little test application to verify something odd I observed and it appears that System.Drawing.Font fails to dispose of its FontFamily. ...
0
by: Martin Streller | last post by:
Hello, The code below represents a simple ownerdrawn, Listview class in C#. Its purpose is to avoid the flicker of the MS ListView. So I can't fall back to their one. Does anybody know why I...
2
by: Stuart Norris | last post by:
Dear Group, I am new to c# and windows form designer - coming from a Motif background. I am attempting to develop an application for a touch screen and I need to have a menu system with a...
3
by: Phil Atkin | last post by:
(Posted here because nobody wants to answer me in framework.interop, and I _am_ using VC++!) IFont to System::Drawing::Font is easy enough: get the hFont property and then use Font::FromHfont. ...
2
by: KV | last post by:
Hi, I'm new to VB.NET and I'm trying to do something rather simple that has turned out to be a pain in the hindside. I'm developing a webpart. All I want to do is change the font of a label on...
7
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and...
2
by: piercy | last post by:
The project im working on requires the user to be able to print reports based on information the program gathers. (ie.To, From, Cost, Username etc.etc.). Now to make this report thing more usable...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.