Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6366753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:27:43+00:00 2026-05-25T00:27:43+00:00

I am trying to receive the image form Server and want to display it

  • 0

I am trying to receive the image form Server and want to display it into a Picturebox in WM Application. I am successfully receiving the Image Stream and I don’t find any way to display it into a PictureBox. In windows program we have a method in Image class that is FromStream (Image.FromStream) but this function is not available in Compact Framework 3.5. I also tried the following code to do so:

    private void button1_Click(object sender, EventArgs e)
    {
        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        IPAddress IP = IPAddress.Parse("192.168.1.2");
        IPEndPoint IPE = new IPEndPoint(IP, 4321);
        s.Connect(IPE);
        byte[] buffer = new byte[55296];
        s.Receive(buffer, buffer.Length, SocketFlags.None);
        MemoryStream ms = new MemoryStream(buffer);
        Image im = new Bitmap(ms); //EXCEPTION
        pictureBox1.Image = im; 
    }

But it gives an Exception. No detail is provided with the exception and VS is only displaying a dialogbox with the text “Exception”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:27:44+00:00Added an answer on May 25, 2026 at 12:27 am

    Does your image size is less than the size of the buffer? If not all the excess data is lost and an exception is thrown.

    Also could you try without the buffer length specified.

            using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {
                IPAddress IP = IPAddress.Parse("192.168.1.2");
                IPEndPoint IPE = new IPEndPoint(IP, 4321);
                s.Connect(IPE);
                byte[] buffer = new byte[55296];
                int rec = s.Receive(buffer, SocketFlags.None);
                using (MemoryStream ms = new MemoryStream(buffer, 0, rec))
                {
                    Image im = new Bitmap(ms);
                    pictureBox1.Image = im;
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to receive the url image and post the image into base64
I am trying to receive an image from the Android Gallery via an ACTION_SEND
I receive the following error when trying to run my ASP.NET MVC application: The
I have a Delphi 6 application that receives and processes an image stream from
I´m trying to send a image through tcp to a server, firts getting the
I'm trying to receive a variable length stream from a camera with python, but
I'm trying to convert an image into base64 using javascript, however if I request
In my project I'm trying to display several image files by manipulating the filename
Trying to create a an image acquiring application optimized for a fast scanner (which
I am trying to use AJAX UpdateProgress to display the loading image when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.