C# There Was An Error Reflecting
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
There Was An Error Reflecting Type System Collections Generic List
policies of this site About Us Learn more about Stack Overflow the c# xml serialization there was an error reflecting type company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags there was an error reflecting field Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only
There Was An Error Reflecting Property C#
takes a minute: Sign up There was an error reflecting property 'Lists' up vote 0 down vote favorite I am trying to serialize a custom object into xml with this code: MatchList matchList = converter.Convert(excelStream); XmlSerializer xmlSerializer = new XmlSerializer(typeof(MatchList)); StringWriter stringWriter = new StringWriter(); xmlSerializer.Serialize(stringWriter, matchList); string serializedXml = stringWriter.ToString(); txtResult.Text = serializedXml; However I get the exception above in
There Was An Error Reflecting Type Xmlserializer
the 2nd line: The matchlist object is defined as: public class MatchList { public Header Header { get; set; } [XmlArray("Lists")] [XmlArrayItem("List")] public virtual List Lists { get; set; } } c# xml xml-serialization share|improve this question edited Nov 23 '12 at 17:40 Aubin 8,85212450 asked Nov 23 '12 at 14:55 Luis Valencia - MVP 5,7342599198 the internal
is a custom object, not c# List object. –Luis Valencia - MVP Nov 23 '12 at 14:57 what exception did you get? –Kirill Bestemyanov Nov 23 '12 at 14:57 Please show the code of List class. That said, to avoid confusion, why not using another name than List? –Steve B Nov 23 '12 at 14:59 By any chance, is your List non-public? If I recall correctly, XmlSerializer requires all objects be public. EDIT: Woah, didn't realize your type was List
... can't... but... ****explodes**** –Chris Sinclair Nov 23 '12 at 15:03 You need to post List in the T of List
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta there was an error reflecting type 'system.collections.generic.list 1 Discuss the workings and policies of this site About Us Learn more
There Was An Error Reflecting 'return'
about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack there was an error reflecting property xml serialization c# Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, http://stackoverflow.com/questions/13531470/there-was-an-error-reflecting-property-lists helping each other. Join them; it only takes a minute: Sign up “There was an error reflecting type” in C# up vote 2 down vote favorite I need to serialize and exception, i created a Serializable class [Serializable] public class MessageException : Exception { public string Exception { get; set; } public MessageException() { } public MessageException(System.Exception ex) http://stackoverflow.com/questions/4809651/there-was-an-error-reflecting-type-in-c-sharp { this.Exception = ex.Message.ToString(); } } and i try to call the class from the following exception when it occur catch (Exception ex) { MessageException exception = new MessageException(ex); var exSerializer = new XmlSerializer(typeof(MessageException)); var writer = new StringWriter(); exSerializer.Serialize(writer, exception); writer.Close(); Compair2Files(writer.ToString(), BaseString); } it fails on the second row "var exSerializer = new XmlSerializer(typeof(MessageException));" What I m actually trying to do is when I catch the exception I want to serialized it and then store it into a file for my unit test program. Would you be able to help me thanks in advance Jp c# .net exception serialization share|improve this question edited Jun 10 '11 at 21:43 Maslow 9,9911064149 asked Jan 26 '11 at 20:25 jprbest 27931226 possible duplicate of How to serialize an Exception object in C#? –user405725 Jan 26 '11 at 20:29 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted You cannot serialize exceptions using XmlSerializer. You need to use binary serialization. The base Exception cla