I need to send a message via TCPIP that contains a two
byte binary length of the message, 6 bytes of spaces and
then the text message.

The type initializer for the TCPClient socket threw an
exception when I used the NetworkStream.write method.

I've been able to do this in VB6, but need to re-write
this under .net.

Does anyone know what I can do to fix this using VB.Net?

My code is as follows (comp1 and comp2 contain the binary
length:

Dim b As Byte = Convert.ToByte(comp1, 2)
Dim b2 As Byte = Convert.ToByte(comp2, 2)

Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(b & b2
& " " & strMsg)

Networkstream.Write(sendbytes, 0, sendbytes.length)