SP2 Problems with HttpWebRequest.GetResponse()

O

Ofer B.

Hi Alex
I tried your sample. first with out the SP2.
I close the 2003 Emulator with out saving its state.
than, I ran your sample, it works fine.

after that, I copy the "netcf.all.wce4.X86.cab" file (NET Compact Framework
1.0 SP2 Developer Redistributable) to the 2003 Emulator and answer "Yes" to
replace all.

Than, I ran your sample and got "WebExeption" to the "get" and to the
"Post".

I attached my sample to the "file download". It is running Ok before the SP2
and With WebExeption after SP2.

the 2003 Emulator, my IPAQ 3660, and my QTEK have all, the same behavior.
one more thing, after the installetion of the SP2 on my IPAQ, Icould not use
the internet explorer on the ipaq. and could not connect to my PC. some
thing happened with the connections ???
Ofer


Alex Feinman said:
Chris,

I've just retested on iPaq with SP2 my sample
(http://www.alexfeinman.com/download.asp?doc=FileDownload.zip)
It seems to work fine. Could you try it on your device and in case you are
doing it differently, could you let me know what else should I try?

Alex

Chris Theorin said:
This is happening to me too. A ToString() on the exception object yields
only:

"System.Net.WebException:WebException"

A .Status.ToString() on the WebException object yields:

"ConnectFailure"



Simply uninstall SP2 (use "bare" (no SP) .NET CF in ROM) and run and works
fine...



Alex Feinman said:
Could you provide the complete contents of the WebException (call
.ToString() on it)?


Hi all
I had some code that works fine till the SP2.
I try to download a file from the internet.
after the sp2 I get "WebExeption" for this line: response =
(HttpWebResponse)request.GetResponse();

do any body know how to solve it?

this is the all function

--------------------------------------------------------------------------
-
/// <summary>
/// connect to an internet link, download data, and save it to a file.
/// </summary>
private void DownloadData(string link, string file)
{
HttpWebRequest request;
HttpWebResponse response;
Stream ReceiveStream = null;
FileStream fstr = null;
try
{
request = (HttpWebRequest)WebRequest.Create(link);
request.Credentials = new NetworkCredential(this.txtUserName.Text ,
this.txtUserPass.Text);
response = (HttpWebResponse)request.GetResponse();
ReceiveStream = response.GetResponseStream();
// Now read s into a byte buffer.
byte[] bytes = new byte[100000];
int numBytesToRead = (int)bytes.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = ReceiveStream.Read(bytes, numBytesRead, numBytesToRead);
// The end of the file is reached.
if (n==0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
ReceiveStream.Close();
// numBytesToRead should be 0 now

fstr = new FileStream(file, FileMode.OpenOrCreate,FileAccess.Write);
fstr.Write(bytes, 0, numBytesRead);
fstr.Close();
}
catch(WebException we)
{
throw we;
}
catch(Exception ex)
{
throw ex;
}
finally
{
request = null;
response = null;
}
}
 
O

Ofer B.

OK, every thing is working now.

For the 2002, 2003 Emulators, I had to change the connections settings to
"work", after intalling the sp2 ???

For the Device (IPAQ 3660) I had to Remove the .Net CF and than install the
..Net CF SP2.

installation of the SP2 with out removing the SP1 couse TypeLoadException
for this line:
Uri uriLink = new Uri(link);

Ofer


Ofer B. said:
Hi Alex
I tried your sample. first with out the SP2.
I close the 2003 Emulator with out saving its state.
than, I ran your sample, it works fine.

after that, I copy the "netcf.all.wce4.X86.cab" file (NET Compact Framework
1.0 SP2 Developer Redistributable) to the 2003 Emulator and answer "Yes" to
replace all.

Than, I ran your sample and got "WebExeption" to the "get" and to the
"Post".

I attached my sample to the "file download". It is running Ok before the SP2
and With WebExeption after SP2.

the 2003 Emulator, my IPAQ 3660, and my QTEK have all, the same behavior.
one more thing, after the installetion of the SP2 on my IPAQ, Icould not use
the internet explorer on the ipaq. and could not connect to my PC. some
thing happened with the connections ???
Ofer


Alex Feinman said:
Chris,

I've just retested on iPaq with SP2 my sample
(http://www.alexfeinman.com/download.asp?doc=FileDownload.zip)
It seems to work fine. Could you try it on your device and in case you are
doing it differently, could you let me know what else should I try?

Alex

Chris Theorin said:
This is happening to me too. A ToString() on the exception object yields
only:

"System.Net.WebException:WebException"

A .Status.ToString() on the WebException object yields:

"ConnectFailure"



Simply uninstall SP2 (use "bare" (no SP) .NET CF in ROM) and run and works
fine...



Could you provide the complete contents of the WebException (call
.ToString() on it)?


Hi all
I had some code that works fine till the SP2.
I try to download a file from the internet.
after the sp2 I get "WebExeption" for this line: response =
(HttpWebResponse)request.GetResponse();

do any body know how to solve it?

this is the all function

--------------------------------------------------------------------------
-
/// <summary>
/// connect to an internet link, download data, and save it to a file.
/// </summary>
private void DownloadData(string link, string file)
{
HttpWebRequest request;
HttpWebResponse response;
Stream ReceiveStream = null;
FileStream fstr = null;
try
{
request = (HttpWebRequest)WebRequest.Create(link);
request.Credentials = new NetworkCredential(this.txtUserName.Text ,
this.txtUserPass.Text);
response = (HttpWebResponse)request.GetResponse();
ReceiveStream = response.GetResponseStream();
// Now read s into a byte buffer.
byte[] bytes = new byte[100000];
int numBytesToRead = (int)bytes.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = ReceiveStream.Read(bytes, numBytesRead, numBytesToRead);
// The end of the file is reached.
if (n==0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
ReceiveStream.Close();
// numBytesToRead should be 0 now

fstr = new FileStream(file, FileMode.OpenOrCreate,FileAccess.Write);
fstr.Write(bytes, 0, numBytesRead);
fstr.Close();
}
catch(WebException we)
{
throw we;
}
catch(Exception ex)
{
throw ex;
}
finally
{
request = null;
response = null;
}
}
 
O

Ofer B.

OK, every thing is working now.

For the 2002, 2003 Emulators, I had to change the connections settings to
"work", after intalling the sp2 ???

For the Device (IPAQ 3660) I had to Remove the .Net CF and than install the
..Net CF SP2.

installation of the SP2 with out removing the SP1 couse TypeLoadException
for this line:
Uri uriLink = new Uri(link);

Ofer



Ofer B. said:
Hi Alex
I tried your sample. first with out the SP2.
I close the 2003 Emulator with out saving its state.
than, I ran your sample, it works fine.

after that, I copy the "netcf.all.wce4.X86.cab" file (NET Compact Framework
1.0 SP2 Developer Redistributable) to the 2003 Emulator and answer "Yes" to
replace all.

Than, I ran your sample and got "WebExeption" to the "get" and to the
"Post".

I attached my sample to the "file download". It is running Ok before the SP2
and With WebExeption after SP2.

the 2003 Emulator, my IPAQ 3660, and my QTEK have all, the same behavior.
one more thing, after the installetion of the SP2 on my IPAQ, Icould not use
the internet explorer on the ipaq. and could not connect to my PC. some
thing happened with the connections ???
Ofer


Alex Feinman said:
Chris,

I've just retested on iPaq with SP2 my sample
(http://www.alexfeinman.com/download.asp?doc=FileDownload.zip)
It seems to work fine. Could you try it on your device and in case you are
doing it differently, could you let me know what else should I try?

Alex

Chris Theorin said:
This is happening to me too. A ToString() on the exception object yields
only:

"System.Net.WebException:WebException"

A .Status.ToString() on the WebException object yields:

"ConnectFailure"



Simply uninstall SP2 (use "bare" (no SP) .NET CF in ROM) and run and works
fine...



Could you provide the complete contents of the WebException (call
.ToString() on it)?


Hi all
I had some code that works fine till the SP2.
I try to download a file from the internet.
after the sp2 I get "WebExeption" for this line: response =
(HttpWebResponse)request.GetResponse();

do any body know how to solve it?

this is the all function

--------------------------------------------------------------------------
-
/// <summary>
/// connect to an internet link, download data, and save it to a file.
/// </summary>
private void DownloadData(string link, string file)
{
HttpWebRequest request;
HttpWebResponse response;
Stream ReceiveStream = null;
FileStream fstr = null;
try
{
request = (HttpWebRequest)WebRequest.Create(link);
request.Credentials = new NetworkCredential(this.txtUserName.Text ,
this.txtUserPass.Text);
response = (HttpWebResponse)request.GetResponse();
ReceiveStream = response.GetResponseStream();
// Now read s into a byte buffer.
byte[] bytes = new byte[100000];
int numBytesToRead = (int)bytes.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = ReceiveStream.Read(bytes, numBytesRead, numBytesToRead);
// The end of the file is reached.
if (n==0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
ReceiveStream.Close();
// numBytesToRead should be 0 now

fstr = new FileStream(file, FileMode.OpenOrCreate,FileAccess.Write);
fstr.Write(bytes, 0, numBytesRead);
fstr.Close();
}
catch(WebException we)
{
throw we;
}
catch(Exception ex)
{
throw ex;
}
finally
{
request = null;
response = null;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top