TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Software World > Programming

Notices

get error in line 'webRequest.GetRequestStream()'

Programming


Reply
 
Thread Tools Display Modes
Old 06-11-2009, 07:13 AM   #1
Newbie
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 funnypeck is an unknown quantity at this point


OS: Windows Vista


Unhappy get error in line 'webRequest.GetRequestStream()'

i'm new in mobile development, i already find many related post for many days. i using Microsoft Visual Studio 2008, language is C#,
hope experts in forum can help me find the solution, thank you.

the code is work fine in desktop application but when move to compact
framework, some error found,one of the error show below:

below is my code

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.Timeout = this.TimeOutMiliSecs;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.KeepAlive = false;

Byte[] bytes = Encoding.GetEncoding("UTF-8").GetBytes(this.Param);
Stream os = null;
WebResponse webResponse = null;
HttpWebResponse response = null;
StreamReader sr = null;
String errorMsg = "-999-" + System.Environment.NewLine;

try
{
webRequest.ContentLength = bytes.Length;
//i get the error 'System.Net.ProtocolViolationException' in this line
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
webResponse = webRequest.GetResponse();
sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.
GetEncoding("UTF-8"));
this.Value = sr.ReadToEnd().Trim();
}

hope the following screenshot can make you more understand what problem i facing:



when run in desktop application, the item inside webRequest without (!)
infront, but when move to mobile application, many item have (!) infront, i
tried to set webRequest.accept= null, but not work.
Please help.....
Attached Images
File Type: jpg screenShot1.jpg (62.4 KB, 0 views)
funnypeck is offline   Reply With Quote
Old 13-11-2009, 01:51 PM   #2
Newbie
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 funnypeck is an unknown quantity at this point


OS: Windows Vista


Re: get error in line 'webRequest.GetRequestStream()'

after i do more testing, i found that the symbol come out after i select "upgrade project" i think HttpWebRequest not support for all platform.

after i downgrade to 2.0, i get another error, i found that StringSplitOptions is not supported, have anyone can point me a correct direction how to fix this error.

funnypeck is offline   Reply With Quote
Reply

Tags
c# code, compact framework, window mobile

Thread Tools
Display Modes



< Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT +5.5. The time now is 11:08 AM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2009, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional