Bug 511715 - DataContractSerializer constructor crashes if one of the 'KnownType' attributes defines a method instead of a type.
Summary: DataContractSerializer constructor crashes if one of the 'KnownType' attribut...
Status: NEW
Alias: None
Product: Mono: Class Libraries
Classification: Mono
Component: WCF (show other bugs)
Version: 2.4.x
Hardware: 32bit Other
: P5 - None : Normal
Target Milestone: ---
Assignee: Noam Lampert
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-10 15:37 UTC by Joseph Fradley
Modified: 2009-07-30 17:40 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Simple stand alone example of problem (1.29 KB, text/plain)
2009-06-10 15:37 UTC, Joseph Fradley
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Fradley 2009-06-10 15:37:24 UTC
Created attachment 297227 [details]
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.