I’ve written small tcp socket client and server applications. Server sends text msg to client.
Part of servers code:
new_sock.Send(Encoding.UTF8.GetBytes("efgh"));
Part of clients code:
byte[] buffer = new byte[100];
int count = sock.Receive(buffer);
sock.Close();
textBox_received.Text = Encoding.UTF8.GetString(buffer);
In windows forms application everything is OK but in WPF application after received text always appears “boxes”:

What is the reason and what can I do to avoid it?
You are getting the string from the whole buffer of 100 bytes, while you actually only received a few. You should only do Encoding.GetString on the bytes you actually received: