cues7a

Hi everybody,

I¡¯m developing an application for Pocket Pc in C#. I use the visual studio 2005 pocket pc emulator

I am trying to do a Http Post using HttpWebRequest but I get a Protocol Violation Exception when I read the response of the server with HttpWebResponse.

The ProtocolViolationException says:

"System.Net.ProtocolViolationException: the response for this request cannot be retrieved until  request data has been written"

Is strange because when I execute my app like a windows form in my PC there is no problem, but when I try my app in the emulator device I  get the Protocol Violation Exception.

Thank you,




Re: Device Emulator General Protocol Violation Exception

Mohit Gogia

Can you please post a sample program Also, please let me know the current configuration of the device emulator.

-Thanks,

Mohit





Re: Device Emulator General Protocol Violation Exception

Malleswar

Hi ,

I have same type of problem. I get this exception when I write through Binary Writer.

private System.IO.BinaryWriter outstream;

private HttpWebRequest httpwebrequest;

HttpWebResponse hwrResponse;

string _serverString = "http://................."; // I am writing my link here

httpwebrequest = (HttpWebRequest)WebRequest.Create(_serverString);
httpwebrequest.Method = "POST";

outstream = new System.IO.BinaryWriter(httpwebrequest.GetRequestStream());

_os.Write(message); // I get the exception here (ProtocolViolationException)


Can any one plz guide me

Thanks in Advance






Re: Device Emulator General Protocol Violation Exception

syncter

If you are writing to the request Stream of HttpWebRequest, make sure it is flushed and closed before retriving response.

i.e.,

requestStream.Flush();
requestStream.Close();




Re: Device Emulator General Protocol Violation Exception

djlins

Hi there, just to help anybody else out in future who may be researchign this problem.

Yes I had exactly the same problem, and yes syncter Flushing and Closinh solved it a treat.

Thanks very much