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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:13:06+00:00 2026-06-07T18:13:06+00:00

I am trying to learn udp sockets etc…. I created two programs server and

  • 0

I am trying to learn udp sockets etc…. I created two programs server and client. The client sends a packet to the server, the server bounces it back.

This is the code I use in both programs for converting the data to and from a byte[]

but I am getting an error when converting from byte[]

public static Packet Open(byte[] b)
        {
            MemoryStream memStream = new MemoryStream();
            BinaryFormatter binForm = new BinaryFormatter();
            memStream.Write(b, 0, b.Length);
            memStream.Seek(0, SeekOrigin.Begin);
            object obj = new object();
            try
            {
                // this line here is where the error is occurring
                obj = (object)binForm.Deserialize(memStream);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            if (obj is Packet)
                return (Packet)obj;
            else
                return null;
        }

        public byte[] Bundle()
        {
            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream ms = new MemoryStream();
            bf.Serialize(ms, this);
            return ms.ToArray();
        }

If I do this, all from one program it works

Packet p =new Packet();
p.Message="hello";

byte[] data = p.Bundle();

Packet p2 = Packet.Open(data);
MessageBox.Show(p2.Message);

The error I am receiving is “unable to find assembly in “the name of my client program”

AnyIdeas?

  • 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-07T18:13:09+00:00Added an answer on June 7, 2026 at 6:13 pm

    It sounds to me like you are serializing a type that is not shared via a reference between both ends. Note: it is not sufficient to have the same class compiled into both, since BinaryFormatter includes the full type name including the assembly, so: it will still count as an unrelated type. The common fix there (and I use the word “fix” entirely incorrectly) is to write an assembly for the DTO and reference that assembly from both client and server. This approach still has many issues, though.

    For info, there are other serializers that are compatible with just having a similar class at each end. I’m biased, but I would suggest having a look at protobuf-net; the output is usually significantly smaller, and it isn’t tied to the type, meaning the class just has to be broadly similar at each end (it is very version tolerant). Plus it is faster (CPU-wise) too!

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

Sidebar

Related Questions

I'm trying to learn UDP, and make a simple file transferring server and client.
I am trying to write a simple program about UDP Connections to learn about
I'm trying to learn WCF and I've created a new WCF Service Library project
I'm trying learn more about RavenDB and at the moment to focus on how
I am trying learn the use of lambda expressions and hence still struggling to
Trying to learn Sencha Touch 2 and I can't seem to find out how
Trying to learn a bit about PDO and is going through this tutorial .
Trying to learn about php's arrays today. I have a set of arrays like
Trying to learn MVP pattern with C#... Does anyone know of any particularly good
im trying to learn delegates and events in c#, i understand that an event

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.