Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. GetType of variable before deserialization possible?

GetType of variable before deserialization possible?

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sam Marrocco
    wrote on last edited by
    #1

    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?

    R L D 3 Replies Last reply
    0
    • S Sam Marrocco

      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?

      R Offline
      R Offline
      Ralf Meier
      wrote on last edited by
      #2

      Perhaps you should what you have done and how you have done it (provide some code) and then we could discuss the possibilities ...

      1 Reply Last reply
      0
      • S Sam Marrocco

        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?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Sam Marrocco

          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?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups