Dexter said:
Overall the code looks ok but what bugs me is the way you read data from the stream:

1) This code expects the stream Position to be correct (probably 0). Is that always the case? Maybe you accidentally passed in a stream that's positioned at the end?
2) You don't check the result of the Stream.Read call. Depending on what type is that stream it is possible that Read returns after reading less that the requested number of bytes.

yeah I'll check the stream a little more.

but what bugs me the most is that the code works in one app but not the other.

the only difference is that I dont declare the connection but get it from another object.

I'll start out to duplicate exactly the code and see if it works, and then look at the stream