473,378 Members | 1,346 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,378 software developers and data experts.

XMLSerializer cannot serialize an object that contains a Font obje

I was trying to use an XML file to save some program settings.
But cannot serialise the settings object if it contains a Font
object (even though Font is maked [Serializable()] in the MS
documentation.

Dies in new XmlSerializer(typeof(JigViewSettings));

What am I doing wrong ?

Code:

[Serializable()] // No change if omitting this line
public class JigViewSettings
{
public Font FontHeading;
public Color ColorTimberFill = Color.Yellow; // works fine if this is
in by itself

public JigViewSettings()
{
FontHeading = new Font("Arial Narrow", 8.0f);
}

static void Save(JigViewSettings settings)
{
XmlSerializer serializer = new
XmlSerializer(typeof(JigViewSettings)); //Dies here
TextWriter writer = new StreamWriter(settings.PathJigViewSettings);
serializer.Serialize(writer, settings);
writer.Close();
}

}

Error:

An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll

Additional information: There was an error reflecting type
'MiTekAUS.mi2020mn.JigViewSettings'.
Nov 12 '05 #1
1 2805
It has come to my notice that even though Font is marked as [Serialzable] in
the MS documentation, it lacks a default constructor.

The lack of a default constructor seems to imply that it cannot be
deserialised ?
Even though I am even having trouble serialising it, let alone deserialising
it.

PS Using Soap I can serialize it but cannot deserialise it.
(see my post under SoapFormatter)

I also tried saving its ToString value, in an appsettings key, but was
surprised to
see that Font's ToString() omits the Fonts Style and as such is an
incomplete desription of the font. However I can work around that. Fonts
ToString() does
include GdiCharSet which does not seem to be explained in the documentation
and appears to me to be possibly a value of a more internal nature ?

I am missing something here ?
Nov 12 '05 #2

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

Similar topics

4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
3
by: Loui Mercieca | last post by:
Hi, I have created a class, named FormField , which basically contains two fields, name and value. I have set the tag before the class and the field is set as an XmlAttribute whil the name as...
4
by: Steve Long | last post by:
Hello, I hope this is the right group to post this to. I'm trying to serialize a class I've written and I'd like to be able to serialze to both binary and xml formats. Binary serialization is...
4
by: Ultrakorne | last post by:
hi, i have some problems with my client talk to my server... i am using xmlserializer to serialize object and send them to the other side of the connection. I need to send / recive by both client...
8
by: cd~ | last post by:
I can provide a test app, the news server won't allow me to post the files because they are too large (93KB and 1.2KB) I downloaded the ESRI ArcXml schema and generated the classes from the...
5
by: Phil Galey | last post by:
I'm using XMLSerializer to serialize hierarchical Class-based objects and their content to XML. There are a number of fields (i.e. properties) that are optional, meaning that if no data id written...
10
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
0
by: Kristopher Wragg | last post by:
Hi, I'm having a problem with XMLSerializer, I have classes like the following: public abstract class EulerObject { private Rectangle rect; private string guid = "";
2
by: christopher.watford | last post by:
I'm loading a plugin assembly using Activator.CreateInstanceFrom, and inside this assembly is a settings class which gets serialized to XML. The general code flow is as follows: ObjectHandle...
1
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.