Click here to Skip to main content
15,905,785 members
Home / Discussions / C#
   

C#

 
GeneralRe: Regex.Replace Question Pin
DevinG4-Jan-07 7:43
DevinG4-Jan-07 7:43 
GeneralRe: Regex.Replace Question Pin
ednrgc4-Jan-07 8:17
ednrgc4-Jan-07 8:17 
AnswerRe: Regex.Replace Question Pin
ednrgc4-Jan-07 3:20
ednrgc4-Jan-07 3:20 
GeneralRe: Regex.Replace Question Pin
DevinG4-Jan-07 7:01
DevinG4-Jan-07 7:01 
QuestionGraphics help Pin
Nooie3-Jan-07 14:47
Nooie3-Jan-07 14:47 
AnswerRe: Graphics help Pin
Chris Buckett3-Jan-07 21:37
Chris Buckett3-Jan-07 21:37 
GeneralRe: Graphics help Pin
Nooie8-Jan-07 21:50
Nooie8-Jan-07 21:50 
QuestionDictionary XML Serialization Problem [modified] Pin
dubbaluga3-Jan-07 13:33
dubbaluga3-Jan-07 13:33 
Hi!

I'm experiencing serialization problems with the .NET XML Serializer on a dictionary datatype:

8<===================================================
...
[Serializable]
public class StringPair
{
public StringPair()
{
m_Key = null; m_Value = null;
}

public StringPair(string p_Key, string p_Value)
{
m_Key = p_Key; m_Value = p_Value;
}

[XmlAttribute("Key")]
public string Key
{
get { return m_Key; }
set { m_Key = value; }
}

[XmlAttribute("Value")]
public string Value
{
get { return m_Value; }
set { m_Value = value; }
}

private string m_Key;
private string m_Value;
}

[Serializable]
public class StringsTable : Dictionary<string, string>, ISerializable, IDeserializationCallback
{
private SerializationInfo _savedSI;

void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
string[] keys = new string[Count];
string[] values = new string[Count];

int i = 0;
foreach (string l_Key in Keys)
{
keys[i] = l_Key;
values[i] = this[l_Key];
++i;
}

info.AddValue("Keys", keys);
info.AddValue("Values", values);
}

public StringsTable()
{

}

protected StringsTable(SerializationInfo info, StreamingContext context)
{
_savedSI = info;
}

void IDeserializationCallback.OnDeserialization(Object sender)
{
string[] keys = (string[])_savedSI.GetValue("Keys", typeof(string[]));
string[] values = (string[])_savedSI.GetValue("Values", typeof(string[]));

for (Int32 i = 0; i < keys.Length; ++i)
Add(keys[i], values[i]);

_savedSI = null;
}
}

[Serializable]
public class Instance
{
public Instance()
{
m_Vars = new StringsTable();
}

[XmlElement("VariableAssignments"]
public StringsTable Variables
{
get
{
return m_Variables;
}
set
{
m_Variables = value;
}
}

private StringsTable m_Vars;
}
...
8<===================================================

This code compiles without any hassles in Visual C# Express 2005. When Serializing an "Instance" object, I always get an InvalidOperationException telling me that "There was an error reflecting type 'Instance'".

What's wrong with my de-/serializatoin?

Thanks in advance,
Rainer
QuestionI need urgent help - thanks Pin
rpsjs3-Jan-07 13:22
rpsjs3-Jan-07 13:22 
AnswerRe: I need urgent help - thanks Pin
Christian Graus3-Jan-07 13:34
protectorChristian Graus3-Jan-07 13:34 
AnswerRe: I need urgent help - thanks Pin
Not Active3-Jan-07 17:56
mentorNot Active3-Jan-07 17:56 
GeneralRe: I need urgent help - thanks Pin
Paul Conrad3-Jan-07 21:26
professionalPaul Conrad3-Jan-07 21:26 
Questionstack heap confusion Pin
swjam3-Jan-07 12:58
swjam3-Jan-07 12:58 
AnswerRe: stack heap confusion Pin
Colin Angus Mackay3-Jan-07 13:02
Colin Angus Mackay3-Jan-07 13:02 
QuestionExplicit interface implementation Pin
Captain See Sharp3-Jan-07 11:23
Captain See Sharp3-Jan-07 11:23 
AnswerRe: Explicit interface implementation Pin
ben23-Jan-07 11:29
ben23-Jan-07 11:29 
AnswerRe: Explicit interface implementation Pin
Daniel Grunwald3-Jan-07 11:40
Daniel Grunwald3-Jan-07 11:40 
GeneralRe: Explicit interface implementation Pin
Captain See Sharp3-Jan-07 13:14
Captain See Sharp3-Jan-07 13:14 
QuestionOleDbData Adapter.Update Command Error Pin
yesufollower3-Jan-07 10:48
yesufollower3-Jan-07 10:48 
AnswerRe: OleDbData Adapter.Update Command Error Pin
ben23-Jan-07 10:51
ben23-Jan-07 10:51 
GeneralRe: OleDbData Adapter.Update Command Error Pin
yesufollower3-Jan-07 10:57
yesufollower3-Jan-07 10:57 
GeneralRe: OleDbData Adapter.Update Command Error Pin
ben23-Jan-07 10:59
ben23-Jan-07 10:59 
GeneralRe: OleDbData Adapter.Update Command Error Pin
yesufollower3-Jan-07 11:37
yesufollower3-Jan-07 11:37 
GeneralRe: OleDbData Adapter.Update Command Error Pin
ben23-Jan-07 11:42
ben23-Jan-07 11:42 
GeneralRe: OleDbData Adapter.Update Command Error Pin
yesufollower3-Jan-07 11:56
yesufollower3-Jan-07 11:56 

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.