locked
Memory Stream RRS feed

  • Question

  • Hello

    I get exception "Parameter cannot be Null" with the below code.  Can some one help me please?

    System.

    Byte[] imageBytes = (System.Byte[])xyz);

     

    MemoryStream mStream = new MemoryStream(imageBytes);

    Thanks

    sameer

    Tuesday, December 21, 2010 8:44 AM

Answers

  • Ensure that xyz is a valid Byte[].

          if ((Byte[])xyz != null)
          {
            
    Byte[] imageBytes = (byte[])xyz;
            
    MemoryStream mStream = new MemoryStream(imageBytes);
          }

    • Proposed as answer by Leo Liu - MSFT Monday, December 27, 2010 7:01 AM
    • Marked as answer by Leo Liu - MSFT Tuesday, December 28, 2010 1:15 AM
    Tuesday, December 21, 2010 9:38 AM
  • That's a useless case in there:

         if (xyz != null)
          {
            MemoryStream mStream = new MemoryStream((byte[])xyz);
          }

    • Proposed as answer by Leo Liu - MSFT Monday, December 27, 2010 7:01 AM
    • Marked as answer by Leo Liu - MSFT Tuesday, December 28, 2010 1:15 AM
    Tuesday, December 21, 2010 12:11 PM
  • Make sure imageBytes is not null.
    • Proposed as answer by Leo Liu - MSFT Monday, December 27, 2010 7:01 AM
    • Marked as answer by Leo Liu - MSFT Tuesday, December 28, 2010 1:15 AM
    Tuesday, December 21, 2010 9:32 AM

All replies

  • Make sure imageBytes is not null.
    • Proposed as answer by Leo Liu - MSFT Monday, December 27, 2010 7:01 AM
    • Marked as answer by Leo Liu - MSFT Tuesday, December 28, 2010 1:15 AM
    Tuesday, December 21, 2010 9:32 AM
  • Ensure that xyz is a valid Byte[].

          if ((Byte[])xyz != null)
          {
            
    Byte[] imageBytes = (byte[])xyz;
            
    MemoryStream mStream = new MemoryStream(imageBytes);
          }

    • Proposed as answer by Leo Liu - MSFT Monday, December 27, 2010 7:01 AM
    • Marked as answer by Leo Liu - MSFT Tuesday, December 28, 2010 1:15 AM
    Tuesday, December 21, 2010 9:38 AM
  • That's a useless case in there:

         if (xyz != null)
          {
            MemoryStream mStream = new MemoryStream((byte[])xyz);
          }

    • Proposed as answer by Leo Liu - MSFT Monday, December 27, 2010 7:01 AM
    • Marked as answer by Leo Liu - MSFT Tuesday, December 28, 2010 1:15 AM
    Tuesday, December 21, 2010 12:11 PM