[Mono-bugs] [Bug 511715] New: DataContractSerializer constructor crashes if one of the 'KnowType' attributes defines a method instead of a type.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jun 10 11:37:25 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=511715


           Summary: DataContractSerializer constructor crashes if one of
                    the 'KnowType' attributes defines a method instead of
                    a type.
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: 32bit
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: WCF
        AssignedTo: noaml at mainsoft.com
        ReportedBy: joe.fradley at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=297227)
 --> (http://bugzilla.novell.com/attachment.cgi?id=297227)
Simple stand alone example of problem

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10)
Gecko/2009042708 Fedora/3.0.10-1.fc9 Firefox/3.0.10

If the constructor of DataContractSerializer is called using a type that has
any KnowType attributes defined using a methodname and not a Type a
NullReferenceException is thrown.

Looking at the source code for DataContractSerializer for version 2.4 it looks
like the problem is in PopulateTypes(). It assumes that a type is always
defined when in fact a methodname could be instead, in which case the method
would need to be called to get the list of known types.


Reproducible: Always

Steps to Reproduce:
1. create a class with [DataContract] attribute and [KnownType(string
methodname)] attribute.
2. Serialize the class using a DataContractSerializer object.

Actual Results:  
Stack Trace:
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
  at System.Runtime.Serialization.KnownTypeCollection.IsPrimitiveNotEnum
(System.Type type) [0x00000] 
  at System.Runtime.Serialization.KnownTypeCollection.TryRegister (System.Type
type) [0x00000] 
  at System.Runtime.Serialization.DataContractSerializer.PopulateTypes
(IEnumerable`1 knownTypes) [0x00000] 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type
type, IEnumerable`1 knownTypes) [0x00000] 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type
type) [0x00000] 



Expected Results:  
No exception.

-- 
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