Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other Compact Framework Posts   Ask New Question  Ask New Question With Power Editor

get error in line 'webRequest.GetRequestStream()'
funnypeck woo posted at Thursday, November 05, 2009 9:18 PM

i'm new in mobile platform, 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 = 12000;
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.....
Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0
Prolem cause by upgrade the project to 3.5
funnypeck woo replied to funnypeck woo on Friday, November 13, 2009 3:12 AM

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, thank you
Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0