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

C#

 
QuestionAdd-in open designer Pin
thrakazog21-Apr-07 5:11
thrakazog21-Apr-07 5:11 
QuestionPath to application folder Pin
gammet21-Apr-07 4:07
gammet21-Apr-07 4:07 
AnswerRe: Path to application folder Pin
Stefan Troschuetz21-Apr-07 5:39
Stefan Troschuetz21-Apr-07 5:39 
GeneralRe: Path to application folder Pin
Bryan Ray21-Apr-07 17:22
Bryan Ray21-Apr-07 17:22 
AnswerRe: Path to application folder Pin
MSilviu21-Apr-07 18:59
MSilviu21-Apr-07 18:59 
GeneralRe: Path to application folder Pin
gammet22-Apr-07 21:33
gammet22-Apr-07 21:33 
QuestionSerialization problem Pin
NaNg1524121-Apr-07 3:06
NaNg1524121-Apr-07 3:06 
AnswerRe: Serialization problem Pin
mdv11321-Apr-07 9:53
mdv11321-Apr-07 9:53 
I don’t really understand what the problem is you are experiencing but I could tell you how I serialize into a binary stream I stream can be send or saved to file. Serializing to XML goes the same way. Note both serializer and deserializer and the object definition of the object to serialize should be the same at the sending and receiving end. To ensure this I simply put the classes in a dll which both sides use. With dotnet 1.x the formatter will give an exception when a version difference is detected. In dotnet 2.0 the formatter will serialize everything it recognizes even if there are version differences. The class to serialize should be declared with [Serializable]


///
/// Serialize object to byte array, object must be Serializable
///

/// <param name="someobject" />object to serialize
/// <returns>array
public byte[] Serialize(T someobject)
{
byte[] objectstream=null;
BinaryFormatter f = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
f.Serialize(stream, someobject);
stream.SetLength( stream.Position);
objectstream = stream.GetBuffer();
return objectstream;
}
public void Deserialize(byte[] stream, out T someobject)
{
BinaryFormatter f = new BinaryFormatter();
MemoryStream serstream = new MemoryStream(stream);
someobject = (T)f.Deserialize(serstream);
}

Class def of class to serialize:

[Serializable]
public class SetConfigMessage
{
public string Name = "";
public string Value = "";
///
/// Config message
///

/// <param name="name" />
/// <param name="svalue" />
public SetConfigMessage() { }
public SetConfigMessage(string name, string value)
{
this.Name = name;
this.Value = value;
}
}


madv113
GeneralRe: Serialization problem Pin
NaNg1524122-Apr-07 10:59
NaNg1524122-Apr-07 10:59 
Questionremoting server encountred Pin
kalyan_241621-Apr-07 0:51
kalyan_241621-Apr-07 0:51 
AnswerRe: remoting server encountred Pin
kubben21-Apr-07 1:52
kubben21-Apr-07 1:52 
GeneralRe: remoting server encountred Pin
kalyan_241621-Apr-07 7:22
kalyan_241621-Apr-07 7:22 
QuestionBoxing when calling a member fn on a struct ? Pin
peterchen21-Apr-07 0:22
peterchen21-Apr-07 0:22 
AnswerRe: Boxing when calling a member fn on a struct ? Pin
Christian Graus21-Apr-07 0:44
protectorChristian Graus21-Apr-07 0:44 
GeneralRe: Boxing when calling a member fn on a struct ? Pin
peterchen21-Apr-07 1:07
peterchen21-Apr-07 1:07 
GeneralRe: Boxing when calling a member fn on a struct ? Pin
Christian Graus21-Apr-07 1:17
protectorChristian Graus21-Apr-07 1:17 
GeneralRe: Boxing when calling a member fn on a struct ? Pin
peterchen21-Apr-07 2:48
peterchen21-Apr-07 2:48 
AnswerRe: Boxing when calling a member fn on a struct ? Pin
Jaiprakash M Bankolli21-Apr-07 4:30
Jaiprakash M Bankolli21-Apr-07 4:30 
AnswerRe: Boxing when calling a member fn on a struct ? Pin
S. Senthil Kumar22-Apr-07 7:37
S. Senthil Kumar22-Apr-07 7:37 
Questionhelp in assembly Pin
Shuaib wasif khan20-Apr-07 23:36
Shuaib wasif khan20-Apr-07 23:36 
AnswerRe: help in assembly Pin
Christian Graus21-Apr-07 0:45
protectorChristian Graus21-Apr-07 0:45 
AnswerRe: help in assembly Pin
peterchen21-Apr-07 0:55
peterchen21-Apr-07 0:55 
QuestionImporting Data from Excel sheet to .net application. Pin
tirumal123120-Apr-07 23:19
tirumal123120-Apr-07 23:19 
AnswerRe: Importing Data from Excel sheet to .net application. Pin
ParimalaRadjaram20-Apr-07 23:42
ParimalaRadjaram20-Apr-07 23:42 
AnswerRe: Importing Data from Excel sheet to .net application. Pin
sthotakura20-Apr-07 23:44
sthotakura20-Apr-07 23:44 

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.