Click here to Skip to main content
15,899,634 members
Home / Discussions / C#
   

C#

 
GeneralRe: Convert - Repost Pin
Luc Pattyn7-Feb-10 3:32
sitebuilderLuc Pattyn7-Feb-10 3:32 
GeneralRe: Convert - Repost Pin
harold aptroot7-Feb-10 5:17
harold aptroot7-Feb-10 5:17 
GeneralRe: Convert - Repost Pin
OriginalGriff7-Feb-10 5:22
mveOriginalGriff7-Feb-10 5:22 
GeneralRe: Convert - Repost Pin
Wes Aday8-Feb-10 4:52
professionalWes Aday8-Feb-10 4:52 
GeneralRe: Convert - Repost Pin
Wes Aday8-Feb-10 4:48
professionalWes Aday8-Feb-10 4:48 
QuestionAlt+N click method Pin
kailuaboy6-Feb-10 17:31
kailuaboy6-Feb-10 17:31 
QuestionBinary serialization Pin
hain6-Feb-10 17:10
hain6-Feb-10 17:10 
AnswerRe: Binary serialization Pin
harold aptroot6-Feb-10 23:39
harold aptroot6-Feb-10 23:39 
That's probably because in .NET the standard serialization includes data that identifies the assembly in which the type was declared, and refuses to deserialize it to an other type that "just happens to have the same structure", if you declare that type in an dll shared by both programs it should work.
Or, you could manually (de)serialize your data (with a BinaryWriter and a BinaryReader, for example), the resulting data will also be a lot smaller since you don't really need to include insanely accurate type information (you could use a couple of bytes to identify the type if you have lots of different types of objects that you're serializing)
In my experience it's rare to have more than 256 different "upper types", and the type of everything else can be determined by position, and I'm going to throw in a stupid example because I'm bored:

abstract class Message
{
    int messageID;

    public Message(BinaryReader r)
    {
        messageID = r.ReadInt32();
    }

    public static Message Deserialize(BinaryReader r)
    {
        switch (r.ReadByte())
        {
            case 0:
                return new SomeSpecificMessageWithData(r);
            case 1:
                //some other message
                break;
        }
    }

    public virtual void Serialize(BinaryWriter w)
    {
        w.Write(messageID);
    }
}
class SomeSpecificMessageWithData : Message
{
    int somethingOrOther;
    float a_float;
    string name;
    const byte TypeID = 0;

    public SomeSpecificMessageWithData(BinaryReader r)
        : base(r)
    {
        somethingOrOther = r.ReadInt32();
        name = r.ReadString();
        a_float = r.ReadSingle();
    }

    public override Serialize(BinaryWriter w)
    {
        w.Write(TypeID);
        base.Serialize(w);
        w.Write(somethingOrOther);
        w.Write(name);
        w.Write(a_float);
    }
}

I know many people prefer the build-in serialization of .NET, and it's certainly easier (less code to write), but it has some very big disadvantages: it's slow as hell (so slow that there are questions about how to make it faster quite often in this forum), it produces a lot of overhead in the data, it's hard to customize and the resulting data makes little sense to other platforms (that may not always be a consideration)
GeneralRe: Binary serialization Pin
OriginalGriff6-Feb-10 23:59
mveOriginalGriff6-Feb-10 23:59 
GeneralRe: Binary serialization Pin
harold aptroot7-Feb-10 0:13
harold aptroot7-Feb-10 0:13 
GeneralRe: Binary serialization Pin
hain7-Feb-10 4:02
hain7-Feb-10 4:02 
QuestionLabel Edit Bug with Treeview, MDI Container and MDIChildForms Pin
CrazyNinjaMike26-Feb-10 16:27
CrazyNinjaMike26-Feb-10 16:27 
QuestionGetting values to Add up from a datagrid text box Pin
miggs706-Feb-10 13:49
miggs706-Feb-10 13:49 
AnswerRe: Getting values to Add up from a datagrid text box Pin
OriginalGriff6-Feb-10 21:42
mveOriginalGriff6-Feb-10 21:42 
GeneralMessage Removed Pin
7-Feb-10 3:12
miggs707-Feb-10 3:12 
GeneralRe: Getting values to Add up from a datagrid text box [modified] Pin
OriginalGriff7-Feb-10 4:33
mveOriginalGriff7-Feb-10 4:33 
GeneralRe: Getting values to Add up from a datagrid text box Pin
miggs707-Feb-10 5:04
miggs707-Feb-10 5:04 
GeneralRe: Getting values to Add up from a datagrid text box Pin
OriginalGriff7-Feb-10 5:12
mveOriginalGriff7-Feb-10 5:12 
GeneralRe: Getting values to Add up from a datagrid text box Pin
miggs707-Feb-10 6:10
miggs707-Feb-10 6:10 
GeneralRe: Getting values to Add up from a datagrid text box Pin
OriginalGriff7-Feb-10 8:17
mveOriginalGriff7-Feb-10 8:17 
GeneralMessage Removed Pin
7-Feb-10 11:13
miggs707-Feb-10 11:13 
GeneralRe: Getting values to Add up from a datagrid text box Pin
OriginalGriff7-Feb-10 22:31
mveOriginalGriff7-Feb-10 22:31 
GeneralMessage Removed Pin
8-Feb-10 1:48
miggs708-Feb-10 1:48 
GeneralRe: Getting values to Add up from a datagrid text box Pin
OriginalGriff8-Feb-10 2:05
mveOriginalGriff8-Feb-10 2:05 
Questionoverlapping area of n ractangles Pin
hotthoughtguy6-Feb-10 10:41
hotthoughtguy6-Feb-10 10:41 

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.