I designed each server and client as seperated projects but they both has the classes in same namespaces
When I try to deserialize i get this:
Unable to find assembly 'RentACar, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.'

Here is my class i want to send objects as packets

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RentACarServer;
namespace RentACarServer
{
    [System.Serializable]
    public class IletisimPaketi
    {
        public enum PAKETTIPI{LOGIN,SIGNUP,CEVAP,DATATABLE}
        public User user;
        public PAKETTIPI tip;



    }
}

Here is my user class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RentACarServer
{
    [System.Serializable]
    public class User
    {
        public string Name, Telno, Tc,Pass;
        public bool isConnected;
    }
}

The client example in my Server

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
namespace RentACarServer
{
    public class Client
    {
        StreamWriter wr;
        StreamReader rd;
        Socket soket;
        NetworkStream stream;
        Thread THRpaketAl;
        BinaryFormatter bf;
        public Client(Socket soket)
        {
            this.soket = soket;
            stream = new NetworkStream(soket);
            wr = new StreamWriter(stream);
            rd = new StreamReader(stream);
            bf = new BinaryFormatter();
            THRpaketAl = new Thread(new ThreadStart(paketAl));
            THRpaketAl.Start();
        }
        public void paketAl()
        {
            while(soket.Connected)
            {
                object paket = bf.Deserialize(stream);
                if(paket != null)
                {
                    IletisimPaketi ipaket = (IletisimPaketi)paket;
                    if(ipaket.tip == IletisimPaketi.PAKETTIPI.LOGIN)
                    {
                        MessageBox.Show(ipaket.user.Tc+":"+ipaket.user.Pass+" Wants to login");
                    }
                }
                Thread.Sleep(500);
            }
        }
    }
}

The actual client

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using RentACarServer;
using System.Runtime.Serialization.Formatters.Binary;

namespace RentACar
{
    public class Client
    {
        TcpClient client;
        NetworkStream stream;
        StreamWriter writer;
        StreamReader reader;
        BinaryFormatter bf;
        IletisimPaketi paket;
        public Client(string ip="127.0.0.1",int port=2525)
        {
            client= new TcpClient(ip, port);
            if(client.Connected)
            {
                stream = client.GetStream();
                writer = new StreamWriter(stream);
                reader = new StreamReader(stream);
                bf = new BinaryFormatter();
                paket = new IletisimPaketi();
                MessageBox.Show("connected");
            }
        }
        public void GirisYap(User user)
        {
            paket.tip = IletisimPaketi.PAKETTIPI.LOGIN;
            paket.user = user;
            bf.Serialize(stream,paket);

        }
        public void KayitOl(User user)
        {

        }
    }

}

OKAY I SOLVED
my solution was removing theese classes from projects and create a library which has both.
than i added library to both projects

I’m glad you were able to figure it out on your own. Thank you for following up with what you did to fix it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.