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. C#
  4. The input stream is not a valid binary format.

The input stream is not a valid binary format.

Scheduled Pinned Locked Moved C#
csharpwcfcomsysadminarchitecture
4 Posts 3 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.
  • R Offline
    R Offline
    RB Emphasys
    wrote on last edited by
    #1

    Alright, I'll admit, after days of looking at this code I'm a bit at my wits end. At a high level it's a project that uses a client server architecture to deliver a stream object via wcf for large data transfers. The blog and project I've utilized can be found here: http://blogs.msdn.com/b/webapps/archive/2012/09/06/custom-wcf-streaming.aspx[^] My issue is this, the project works incredibly well with numeric values. But, if I add a few basic string values in, it'll process say 30 rows of data and then die, with the following message: "The input stream is not a valid binary format. The starting contents (in bytes) are: 08-02-00-00-00-0A-00-00-00-0A-00-00-00-0A-00-00-00 ... A summarized version of the code looks like this: Server:

    model.ID = i;
    model.ParameterOne = i;
    model.ParameterTwo = i;
    model.ParameterThree = i;
    model.AMP = stringCache[i - 1];

    formatter.Serialize(memStream, model);

    Client:

    OrderModel m;
    while (s.CanRead)
    {
    m = formatter.Deserialize(s) as OrderModel;
    count++;
    Console.Write(string.Format("order ID is {0}\r\n", m.ID));
    }

    I've run through multiple scenarios. I thought the wcf client was either timing out or being overloaded, but I can run it without wcf all in the same class and run into the same exact issue. I can also manually read and write to a memory stream not utilizing the server class and it works perfectly fine, so that proves it can't be encoding or issues with that data in general. You can download the same project here (just three classes): https://skydrive.live.com/redir.aspx?cid=8df0b4ca8325874a&page=self&resid=8DF0B4CA8325874A%21175&parid=8DF0B4CA8325874A%21110&authkey=%21&Bpub=SDX.SkyDrive&Bsrc=Share[^] If you go to class DBRowStream and comment line 179, it works beautifully. If you uncomment it, it fail

    L E 2 Replies Last reply
    0
    • R RB Emphasys

      Alright, I'll admit, after days of looking at this code I'm a bit at my wits end. At a high level it's a project that uses a client server architecture to deliver a stream object via wcf for large data transfers. The blog and project I've utilized can be found here: http://blogs.msdn.com/b/webapps/archive/2012/09/06/custom-wcf-streaming.aspx[^] My issue is this, the project works incredibly well with numeric values. But, if I add a few basic string values in, it'll process say 30 rows of data and then die, with the following message: "The input stream is not a valid binary format. The starting contents (in bytes) are: 08-02-00-00-00-0A-00-00-00-0A-00-00-00-0A-00-00-00 ... A summarized version of the code looks like this: Server:

      model.ID = i;
      model.ParameterOne = i;
      model.ParameterTwo = i;
      model.ParameterThree = i;
      model.AMP = stringCache[i - 1];

      formatter.Serialize(memStream, model);

      Client:

      OrderModel m;
      while (s.CanRead)
      {
      m = formatter.Deserialize(s) as OrderModel;
      count++;
      Console.Write(string.Format("order ID is {0}\r\n", m.ID));
      }

      I've run through multiple scenarios. I thought the wcf client was either timing out or being overloaded, but I can run it without wcf all in the same class and run into the same exact issue. I can also manually read and write to a memory stream not utilizing the server class and it works perfectly fine, so that proves it can't be encoding or issues with that data in general. You can download the same project here (just three classes): https://skydrive.live.com/redir.aspx?cid=8df0b4ca8325874a&page=self&resid=8DF0B4CA8325874A%21175&parid=8DF0B4CA8325874A%21110&authkey=%21&Bpub=SDX.SkyDrive&Bsrc=Share[^] If you go to class DBRowStream and comment line 179, it works beautifully. If you uncomment it, it fail

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

      It's multithreaded; could it be that the memorystream is corrupted before the thread finishes?

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

      R 1 Reply Last reply
      0
      • L Lost User

        It's multithreaded; could it be that the memorystream is corrupted before the thread finishes?

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

        R Offline
        R Offline
        RB Emphasys
        wrote on last edited by
        #3

        You know I was wondering the same thing. Although it's odd that it makes it through exactly 30 rows every single time before it errors out. I was also thinking that because the author switches the memory stream from one of two other memory streams, that maybe the main memory stream is being overridden before a read is complete....

        1 Reply Last reply
        0
        • R RB Emphasys

          Alright, I'll admit, after days of looking at this code I'm a bit at my wits end. At a high level it's a project that uses a client server architecture to deliver a stream object via wcf for large data transfers. The blog and project I've utilized can be found here: http://blogs.msdn.com/b/webapps/archive/2012/09/06/custom-wcf-streaming.aspx[^] My issue is this, the project works incredibly well with numeric values. But, if I add a few basic string values in, it'll process say 30 rows of data and then die, with the following message: "The input stream is not a valid binary format. The starting contents (in bytes) are: 08-02-00-00-00-0A-00-00-00-0A-00-00-00-0A-00-00-00 ... A summarized version of the code looks like this: Server:

          model.ID = i;
          model.ParameterOne = i;
          model.ParameterTwo = i;
          model.ParameterThree = i;
          model.AMP = stringCache[i - 1];

          formatter.Serialize(memStream, model);

          Client:

          OrderModel m;
          while (s.CanRead)
          {
          m = formatter.Deserialize(s) as OrderModel;
          count++;
          Console.Write(string.Format("order ID is {0}\r\n", m.ID));
          }

          I've run through multiple scenarios. I thought the wcf client was either timing out or being overloaded, but I can run it without wcf all in the same class and run into the same exact issue. I can also manually read and write to a memory stream not utilizing the server class and it works perfectly fine, so that proves it can't be encoding or issues with that data in general. You can download the same project here (just three classes): https://skydrive.live.com/redir.aspx?cid=8df0b4ca8325874a&page=self&resid=8DF0B4CA8325874A%21175&parid=8DF0B4CA8325874A%21110&authkey=%21&Bpub=SDX.SkyDrive&Bsrc=Share[^] If you go to class DBRowStream and comment line 179, it works beautifully. If you uncomment it, it fail

          E Offline
          E Offline
          Ennis Ray Lynch Jr
          wrote on last edited by
          #4

          formatter.Deserialize(s) assumes that the entire object has been successfully written to the stream? For grins and giggle, try writing the entire stream to memory after 30 rows; I bet a dime to a dollar, all of your strings have not been completely written. At least that is what I would look into, don't know the answer myself as I completely avoid WCF like the plague.

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

          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