473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[XmlInclude(type of(System.Drawi ng.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(type of(System.Drawi ng.Font))]
[XmlRoot("ProMod elChartFX")]
public class MyClass
{
Font font;
public Font Font
{
get{return font;}
set{font = value;}
}
public MyClass(){}
}

Whenever I try to:
XmlSerializer ser = new XmlSerializer(t ypeof(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 2052
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.InvalidO perationExcepti on
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
4190
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 structure. I seem to be doing this correctly, but when I try to create a System.Drawing.Font object with the Font.FromLogFont, the new Font object has a different Name than the LOGFONT.
0
1529
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, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); ..... graphics.DrawString(strtmp,this.Font,this.brushBlack, DrawStringValidRect(ref ,graphics,this.Font ,
3
7223
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. I run the following code: // BEGIN while( true ) { System.Drawing.Graphics dc=lblClock.CreateGraphics();
0
2617
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 cannot change the size of the ListView's font (ListView.Font) from e.g.
2
2849
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 larger font to allow ease of selection. I have used OwnerDraw menus implementing the DrawItemEventHandler and
3
1663
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. But how can I go from a Font to a corresponding IFont? TIA
2
5833
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 it. The label is created at runtime. I use the following code: Dim lblDate as Label = New Label lblDate.Text = Date.Today
7
2973
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 already formatted as "Shopping" ---Bold "for" -----Regular Now I want to underline whole text by preserving old style i.e. Bold and
2
7736
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 im going to add lots of customizable options. For instance, row color, font size, font type, font color, header color etc. So i added the fontDialog control to my page and for time being just called ShowDialog on a button click. Theres an...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.