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 8806203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:04:26+00:00 2026-06-14T02:04:26+00:00

i try to send Image Object as serialized File from Client to Server by

  • 0

i try to send Image Object as serialized File from Client to Server by @TCP
And get this exception

 image exception

Server Code

 namespace Receiver
  {
 [Serializable()]
   public class ImageSerial : ISerializable
   {
    public Image img = null;

    public ImageSerial(SerializationInfo info, StreamingContext ctxt)
    {
        img = (Image)info.GetValue("OMG", typeof(Image));
    }
    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        info.AddValue("OMG", img);
    }
}

public class ObjSerial
{
    private Stream stream;
    private BinaryFormatter bformatter;
    private string FILENAME = "m.bin";
    ImageSerial mp = new ImageSerial();

    public Image getImgFromBin()
    {

        stream = File.Open(FILENAME, FileMode.Open);
        bformatter = new BinaryFormatter();

        mp = (ImageSerial)bformatter.Deserialize(stream);
        stream.Close();
        return mp.img;
    }

Client code

    namespace WindowsFormsApplication5
    {
   [Serializable()]
     class ImageSerial :ISerializable
    {
    public Image img = null;
    public ImageSerial() { }

    public ImageSerial(SerializationInfo info, StreamingContext ctxt)
      { 
           img = (Image)info.GetValue("OMG", typeof(Image));
      }
    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
       info.AddValue("OMG",img);
    }
}

public class ObjSerial
{
   private string FILENAME = "m.bin";
   private TcpClient tcpClient;
   private FileStream fstFile;
   private NetworkStream strRemote;
   private string SERVERIP = "10.102.239.207";
   private int SERVERPort = 5051;

    public  void start(Image ims)
    {

        ImageSerial mp = new ImageSerial();
        mp.img = ims;

        Stream stream = File.Open(FILENAME, FileMode.Create);
        BinaryFormatter bformatter = new BinaryFormatter(); 

        bformatter.Serialize(stream, mp);
        stream.Close();

        //Clear mp for further usage.
        sendFile();



       }
       private void ConnectToServer(string ServerIP, int ServerPort)
       {  
        tcpClient = new TcpClient();
        try
        { 
            tcpClient.Connect(ServerIP, ServerPort);
        }
        catch (Exception exMessage)
        {
            // Display any possible error
        }
    }

    private void sendFile()
    {

        ConnectToServer(SERVERIP, SERVERPort);
        if (tcpClient.Connected == false)
        { 
            ConnectToServer(SERVERIP, SERVERPort);
        } 
        strRemote = tcpClient.GetStream();
        fstFile = new FileStream(FILENAME, FileMode.Open, FileAccess.Read);

        int bytesSize = 0; 
        byte[] downBuffer = new byte[2048];

        while ((bytesSize = fstFile.Read(downBuffer, 0, downBuffer.Length)) > 0)
        {
             strRemote.Write(downBuffer, 0, bytesSize);
        }
        tcpClient.Close();
        strRemote.Close();
        fstFile.Close();


    }
    }

i have read many topic about this exception and all of them talk about two solution

  • formatter.Binder
  • AppDomain.CurrentDomain.AssemblyResolve

but still not work

  • 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-06-14T02:04:27+00:00Added an answer on June 14, 2026 at 2:04 am

    Of course the server side will not find the client side assembly. And it should not. Your client side code must not live in the server side. The problem here is that you defined your ImageSerial class twice, one in the server and one in the client. That’s plain wrong if you control both sides. Create a common assembly that is referenced by both the client and the server and put your common classes there.

    Also, remove all references from the server to the client. It should be the other way bound if you wish, or use an intermediate service layer such as WCF.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to read in image file from a server , with the code
I try to send a request to my server via GET, but qooxdoo sends
i try to send some data to my php file from ajax , but
I'm using the Forge file module to try and upload an image from the
i run some code to connect to a server, send it an Object and
I need to Send Image from silverlight to WCF service. I try to do
I try to send json array to ajax (from PHP to jQuery) in my
I try to send a sms using next code, but recipient gets my message
I try to send a message from to global page to my injected.js on
In Mail, when I add an image and try to send it, it quickly

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.