Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)

I have started developing a windows mobile application on Visual Studio 2005 and I want to get connected to an external web service. My code is as follows:
Private Function getData(ByVal xmlReq As String) As DataSet
Dim ds As New DataSet()
Dim WReq As WebRequest = WebRequest.Create(WSURL)
WReq.PreAuthenticate = False
WReq.Method = "POST"
WReq.ContentType = "application/xml; charset=utf-8"
WReq.Headers.Add("SOAPAction", WSURL)
WReq.Timeout = System.Threading.Timeout.Infinite
WReq.ContentLength = xmlReq.Length

Dim sw = New StreamWriter(WReq.GetRequestStream())
Dim objWebResponse As WebResponse = WReq.GetResponse()
Dim objStream As Stream = objWebResponse.GetResponseStream()
Dim xr As New XmlTextReader(objStream)
Catch ex As Exception
Return Nothing
End Try
Return ds
End Function

The problem occurs at sw.write and sw.close ... It says following error:
"The targeted version of the .Net Compact Framework does not support latebinding."

The code works fine in Web Forms and Windows Form, But gives error in Windows Mobile Application with Visual Studio 2005.

Any help would be appreciated!
Updated 2-Jul-12 6:48am

It's because you declared
Dim sw = New StreamWriter...

You didn't specify the type sw was supposed to be.

Change the line to:
Dim sw As New StreamWriter...
Share this answer
[no name] 2-Jul-12 12:36pm    
I see it now. Nevermind.
Thanks for that, but the same thing works with VS 2010...nyways thanks!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900