Binary stream 'NN' does not contain a valid BinaryHeader. Possible causes are invalid stream or obje
Posted
by FinancialRadDeveloper
on Stack Overflow
See other posts from Stack Overflow
or by FinancialRadDeveloper
Published on 2009-12-16T18:22:23Z
Indexed on
2010/04/18
11:13 UTC
Read the original article
Hit count: 529
I am passing user defined classes over sockets. The SendObject code is below. It works on my local machine, but when I publish to the WebServer which is then communicating with the App Server on my own machine it fails.
public bool SendObject(Object obj, ref string sErrMsg)
{
try
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf1 = new BinaryFormatter();
bf1.Serialize(ms, obj);
byte[] byArr = ms.ToArray();
int len = byArr.Length;
m_socClient.Send(byArr);
return true;
}
catch (Exception e)
{
sErrMsg = "SendObject Error: " + e.Message;
return false;
}
}
I can do this fine if it is one class in my tools project and the other class about UserData just doesn't want to know. Frustrating!
Ohh. I think its because the UserData class has a DataSet inside it. Funnily enough I have seen this work, but then after 1 request it goes loopy and I can't get it to work again.
Anyone know why this might be? I have looked at comparing the dlls to make sure they are the same on the WebServer and on my local machine and they look to be so as I have turned on versioning in the AssemblyInfo.cs to double check.
Edit:
Ok it seems that the problem is with size. If I keep it under 1024 byes ( I am guessing here) it works on the web server and doesnt if it has a DataSet inside it.k In fact this is so puzzling I converted the DataSet to a string using ds.GetXml() and this also causes it to blow up. :( So it seems that across the network something with my sockets is wrong and doesn't want to read in the data.
JonSkeet where are you. ha ha. I would offer Rep but I don't have any. Grr
© Stack Overflow or respective owner