GetType of variable before deserialization possible?
-
I am sending information between two vb.net applications using named pipes; serializing the information object, sending it to the second app, then deserializing it. All works well, but I am finding that I need to send more than one type of object. However, I cannot tell the type of serialized object that has been received until *after* it has been deserialized. Is there a method of identifying the object type *before* I deserialize it so I can then cast it into the proper object type when received?
-
I am sending information between two vb.net applications using named pipes; serializing the information object, sending it to the second app, then deserializing it. All works well, but I am finding that I need to send more than one type of object. However, I cannot tell the type of serialized object that has been received until *after* it has been deserialized. Is there a method of identifying the object type *before* I deserialize it so I can then cast it into the proper object type when received?
Perhaps you should what you have done and how you have done it (provide some code) and then we could discuss the possibilities ...
-
I am sending information between two vb.net applications using named pipes; serializing the information object, sending it to the second app, then deserializing it. All works well, but I am finding that I need to send more than one type of object. However, I cannot tell the type of serialized object that has been received until *after* it has been deserialized. Is there a method of identifying the object type *before* I deserialize it so I can then cast it into the proper object type when received?
GetType.ToString, and send that before you send your serialized stuff. How you gonna cast it, is beyond me, I just woke up :)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
I am sending information between two vb.net applications using named pipes; serializing the information object, sending it to the second app, then deserializing it. All works well, but I am finding that I need to send more than one type of object. However, I cannot tell the type of serialized object that has been received until *after* it has been deserialized. Is there a method of identifying the object type *before* I deserialize it so I can then cast it into the proper object type when received?
In situations where people jump into sending objects "over the wire" for the first time, especially where noobs start sending images, is that they just go straight for sending the object or image. Well, if you just picked up the phone and dialed a number, the other side answered, and you just said "this image", the person on the other end of the call isn't going to know what you're talking about or what to do with that information. You haven't set up any context for a conversation. You don't have any protocol in place to describe what you're doing. You have to build your own communication protocol for setting up and maintaining both a conversation and subject context. The conversation should not start with shoving any old object onto the wire. You have to setup a context for conversation, or what you're going to be talking about. For example, start with "I'm going to send you 'such and such' object. The next x number of bytes will be the data for that object". Obviously, you don't send the full text of what I just posted. You send data that means what is in the quotes. Now you have a context to work with. The receiver will have a better idea of what it's looking at when that data shows up and what to do with it. Now, you also have to fill in the details for what to do when the receiver either gets too many bytes, or not enough, and other communication failures.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak