[Mono-bugs] [Bug 573502] New: DataContractSerializer incorrectly reporting a bad XML file

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jan 25 10:40:19 EST 2010



           Summary: DataContractSerializer incorrectly reporting a bad XML
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: x86-64
        OS/Version: RHEL 5
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Sys.XML
        AssignedTo: atsushi at ximian.com
        ReportedBy: mike at realrunners.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Field Engineer
           Blocker: Yes

Description of Problem:
Using the DataContractSerializer and the XmlDictionaryReader classes to
serialize and deserialize a simple object fails. It works in stable 2.6.1.

Steps to reproduce the problem:
given these classes:

    public enum DBDriver
        SQLite = 1,
        MySQL = 2,
        Oracle = 3,
        Postgresql = 4,
        SQLServer = 5

    public class DBConnectionInfo : IComparable<DBConnectionInfo>
        public long ConnectionId { get; set; }
        public string ConnectionName { get; set; }
        public DBDriver Driver { get; set; }
        public string Host { get; set; }
        public int Port { get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
        public string DatabaseName { get; set; }
        public string DBFilePath { get; set; }

    public class Config
        public string DefaultConnectionName {get;set;}
        public string RepoConnectionName {get;set;}

        public string TempFolder {get;set;}
        public string ConfigFilePath {get;set;}

        private List<DBConnectionInfo> _DBConnections;
        public List<DBConnectionInfo> DBConnections
                if (_DBConnections == null)                
                    _DBConnections = new List<DBConnectionInfo>();              
                return _DBConnections; 
            private set { _DBConnections = value; }

This code:

                    DataContractSerializer serz = new
                    using (FileStream fs = new FileStream(configFilePath,
                        using (XmlDictionaryReader xmlReader =
                            XmlDictionaryReader.CreateTextReader(fs, new
                            cfg = (Config)serz.ReadObject(xmlReader);
                catch (Exception ex)
                    Logger.Instance.Log(LoggerType.Logic, LoggerLevel.WARNING,
                        "An error occurred when loading your config file. " +

And this XML:
<?xml version="1.0" encoding="utf-8"?>
<Config xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
  <RepoConnectionName>Hamconf Repo</RepoConnectionName>

You get:

Actual Results:

An error occurred when loading your config file. Deserializing type
'LibRelationalMigration.DBConnectionInfo'. Expecting state 'EndElement'.
Encountered state 'Element' with name 'ConnectionName' with namespace
Failed Capture: You must first set a Repository connection in the application
settings before using the command line tool.
  at RMCmd.Program.SetupConfig (System.String dbPath) [0x00000]
  at RMCmd.Program.Main (System.String[] args) [0x00000]

Expected Results:

No errors... Correctly deserialize the XML and create instances of the classes

How often does this happen? 


Additional Information:

Mono built from mono-142439.tar.bz2

Linux alta #1 SMP Fri Feb 15 12:34:28 EST 2008 x86_64 x86_64
x86_64 GNU/Linux

mono -V
Mono JIT compiler version 142439 (tarball Mon Jan 25 09:44:14 EST 2010)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC and Parallel Mark)
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list