Click here to Skip to main content
15,886,578 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to open a pdf File Pin
Guffa26-Jan-06 21:09
Guffa26-Jan-06 21:09 
GeneralRe: how to open a pdf File Pin
Venkatram.S26-Jan-06 21:30
Venkatram.S26-Jan-06 21:30 
GeneralRe: how to open a pdf File Pin
Kodanda Pani26-Jan-06 22:52
Kodanda Pani26-Jan-06 22:52 
AnswerRe: how to open a pdf File Pin
Arne Kuehn26-Jan-06 23:20
Arne Kuehn26-Jan-06 23:20 
QuestionShow Window Pin
jzb26-Jan-06 18:57
jzb26-Jan-06 18:57 
AnswerRe: Show Window Pin
James Gupta26-Jan-06 21:02
professionalJames Gupta26-Jan-06 21:02 
GeneralRe: Show Window Pin
jzb26-Jan-06 21:46
jzb26-Jan-06 21:46 
QuestionXML Serialization Pin
LighthouseJ26-Jan-06 18:40
LighthouseJ26-Jan-06 18:40 
You may recall I asked about binary serialization earlier. I did it but (after a suggestion from someones' reply) I wanted to try something I never tried before so I want to get my feet wet in XML. As you may recall, I have 2 classes of lists derived from collections (class ArrayList to be specific) with objects in the list (also derived from System.Object). I can serialize both of them into one file but in the file I get:

<MyArray1 count="6">
...
</MyArray1><?xml version="1.0" encoding="utf-8"?>
<MyArray2 count="2">
...
</MyArray2>


That "?xml" tag, which as I understand is the document start tag that states it's XML, what version of XML it is and what encoding it has, should only be at the top and not in the middle.

Here's the core of the XML code:

StreamWriter writer = new StreamWriter(dlg.FileName);<br />
<br />
XmlSerializer ser1 = new XmlSerializer(typeof(Array1));<br />
ser1.Serialize(writer, array1);<br />
<br />
XmlSerializer ser2 = new XmlSerializer(typeof(Array2));<br />
ser.Serialize(writer, array2);<br />
<br />
writer.Close();


I figure it's doing that because the second XML serializer figures it's the only XML serializer so it writes that document start tag which I want to get out of there. I found an overloaded constructor for the XmlSerializer which is (Type, Type[]). I figure that's what I'm looking for because the second argument takes "extra types". I tried creating a Type array with a single element (the typeof(Array2)) and the first argument keeps typeof(Array1) but in runtime, I get an exception that says "Specified cast is not valid" at Write1_Array1. Some web pages say it's because it's trying to cast my derived class as the base class and it doesn't like that but I don't know if they are having the same issue. I don't quite know how to fix this, can anyone help me?
AnswerRe: XML Serialization Pin
leppie26-Jan-06 21:30
leppie26-Jan-06 21:30 
GeneralRe: XML Serialization Pin
LighthouseJ27-Jan-06 5:41
LighthouseJ27-Jan-06 5:41 
QuestionWonder of DataGrid imort from Excel file Pin
Libra26-Jan-06 15:43
Libra26-Jan-06 15:43 
AnswerRe: Wonder of DataGrid imort from Excel file Pin
Kodanda Pani26-Jan-06 20:36
Kodanda Pani26-Jan-06 20:36 
GeneralRe: Wonder of DataGrid imort from Excel file Pin
Libra27-Jan-06 16:21
Libra27-Jan-06 16:21 
QuestionRead and Replace Pin
picasso226-Jan-06 12:29
picasso226-Jan-06 12:29 
AnswerRe: Read and Replace Pin
Ravi Bhavnani26-Jan-06 12:42
professionalRavi Bhavnani26-Jan-06 12:42 
AnswerRe: Read and Replace Pin
DigitalKing26-Jan-06 14:30
DigitalKing26-Jan-06 14:30 
QuestionDisplay live video from an ethernet camera Pin
greg ross26-Jan-06 12:08
greg ross26-Jan-06 12:08 
AnswerRe: Display live video from an ethernet camera Pin
Daniel Santillanes26-Jan-06 13:00
professionalDaniel Santillanes26-Jan-06 13:00 
GeneralRe: Display live video from an ethernet camera Pin
greg ross31-Jan-06 3:18
greg ross31-Jan-06 3:18 
QuestionFun with generics Pin
tantiboh26-Jan-06 12:07
tantiboh26-Jan-06 12:07 
AnswerRe: Fun with generics Pin
Guffa26-Jan-06 12:27
Guffa26-Jan-06 12:27 
AnswerRe: Fun with generics Pin
Le centriste27-Jan-06 1:38
Le centriste27-Jan-06 1:38 
QuestionWindows refresh Pin
Kwai Cheng Kane26-Jan-06 9:43
Kwai Cheng Kane26-Jan-06 9:43 
AnswerRe: Windows refresh Pin
James Gupta26-Jan-06 10:21
professionalJames Gupta26-Jan-06 10:21 
GeneralRe: Windows refresh Pin
Kwai Cheng Kane26-Jan-06 10:28
Kwai Cheng Kane26-Jan-06 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.