Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
General.NET Executable as COM server Pin
mav.northwind24-May-05 20:59
mav.northwind24-May-05 20:59 
GeneralRe: .NET Executable as COM server Pin
John Fisher25-May-05 7:36
John Fisher25-May-05 7:36 
GeneralRe: .NET Executable as COM server Pin
mav.northwind25-May-05 14:34
mav.northwind25-May-05 14:34 
GeneralRe: .NET Executable as COM server Pin
John Fisher25-May-05 17:19
John Fisher25-May-05 17:19 
GeneralInsert Command Pin
Blue_Boy24-May-05 20:41
Blue_Boy24-May-05 20:41 
GeneralRe: Insert Command Pin
pubududilena25-May-05 1:27
pubududilena25-May-05 1:27 
GeneralRe: Insert Command Pin
Uri Lavi25-May-05 8:22
Uri Lavi25-May-05 8:22 
QuestionSerialization Error?? Pin
rufcaw24-May-05 20:27
rufcaw24-May-05 20:27 
MY program is supposed to send a file asychronously via TCP and sockets, to this end i grab

chunks of the file and store it in a data class, which i serialize and send.This is then

deserialized and the data block is placed in the correct spot in the file by offseting the

stream to the appropriate spot.

ok to the error , this process works the first couple of types with atleast the first 2

chunks of data being recieved and placed in a file on the other side. However after that

things go pear shaped, as once one goes wrong all the remaining chunks no longer work all

giving similar errors.

1 //<< this is my sequence number i use to find offset values
0 //<< current offset in file
got to reciever
got to tryrec
2 //<< this is my sequence number i use to find offset values
1024 //<< current offset in file
got to reciever
got to tryrec
A Exception occured in file transferSystem.Runtime.Serialization.SerializationException: The

input stream is not a valid binary format. The starting contents (in bytes) are:

6C-65-2E-52-65-61-64-4C-69-6E-65-28-29-3B-0D-0A-0D ...
at

System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser

input)
at

System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord(

)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler

handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream

serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage

methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream

serializationStream)
at SocketSystem.Program.MessageHandlerServer(CSocketClient pSocket, Int32 iNumberOfBytes)

in c:\documents and

settings\rob\desktop\socketsystem\socketsystem\socketsystem\program.cs:line 274
got to reciever

my data class
[Serializable]<br />
public class DropBear<br />
{<br />
//so this is where in the part belongs<br />
public int SequenceNo = 0;<br />
public string misc = "";<br />
//this is the data<br />
public byte[] buff = null;<br />
<br />
}


---------------------------------------------------------------------------

now for my serialization code

DropBear db = new DropBear();<br />
db.buff = buffered;<br />
db.SequenceNo = filt.currSeqNO++;<br />
BinaryFormatter bf = new BinaryFormatter();<br />
MemoryStream ms = new MemoryStream(); // Stream<br />
bf.Serialize(ms, db); // "Save" object state<br />
Byte[] by = ms.GetBuffer();

//data sent as Byte[] << byte buffer size 10240
//file chunk 1024

----------------------------------------------------------------------------

Deserialization
MemoryStream s = new MemoryStream();<br />
s.Write(pSocket.GetRawBuffer, 0, pSocket.GetRawBuffer.Length);<br />
BinaryFormatter bf = new BinaryFormatter();<br />
s.Position = 0;<br />
DropBear db = (DropBear)bf.Deserialize(s);


-------------------------------------------------------------------

the data is sent with a network stream, i have tryed resetting the buffer at the end of

every read and before every recieve

Any input would be appreciated.

Thanks Rob
AnswerRe: Serialization Error?? Pin
Alomgir Miah25-May-05 3:40
Alomgir Miah25-May-05 3:40 
GeneralBackground image in MDI container Pin
MJay24-May-05 17:59
MJay24-May-05 17:59 
GeneralRe: Background image in MDI container Pin
Rizwan Bashir25-May-05 2:45
Rizwan Bashir25-May-05 2:45 
GeneralRe: Background image in MDI container Pin
Alomgir Miah25-May-05 4:11
Alomgir Miah25-May-05 4:11 
GeneralRe: Background image in MDI container Pin
Skynyrd25-May-05 6:14
Skynyrd25-May-05 6:14 
Generalsearching a collection base Pin
savage_24-May-05 16:28
savage_24-May-05 16:28 
GeneralRe: searching a collection base Pin
Alomgir Miah25-May-05 4:03
Alomgir Miah25-May-05 4:03 
GeneralXML web service Pin
Yulianto.24-May-05 14:57
Yulianto.24-May-05 14:57 
GeneralRe: XML web service Pin
eggie524-May-05 17:49
eggie524-May-05 17:49 
GeneralRe: XML web service Pin
Yulianto.24-May-05 17:52
Yulianto.24-May-05 17:52 
GeneralRe: XML web service Pin
eggie524-May-05 17:56
eggie524-May-05 17:56 
GeneralRe: XML web service Pin
Yulianto.24-May-05 18:01
Yulianto.24-May-05 18:01 
GeneralRe: XML web service Pin
eggie524-May-05 18:09
eggie524-May-05 18:09 
GeneralRe: XML web service Pin
Yulianto.24-May-05 18:14
Yulianto.24-May-05 18:14 
GeneralHelp with Get Set Method of property Pin
monica2k24-May-05 14:43
monica2k24-May-05 14:43 
GeneralRe: Help with Get Set Method of property Pin
Marc Clifton24-May-05 14:49
mvaMarc Clifton24-May-05 14:49 
GeneralGetManifestResourceStream Pin
Marc Clifton24-May-05 11:23
mvaMarc Clifton24-May-05 11:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.