Problema con http connection

mercoledì 05 maggio 2010 - 16.39

carlitos081 Profilo | Newbie

Ciao a tutti

ho scritto un applicazione per windows mobile 6.1 professional e mi sta dando qualche rogna nell'invio di dati tramite http post.
Il codice in questione è:
void DoConnect(string url) {

string rmc = "Dati GPS RMC non disponibili";
string gga = "Dati GPS GGA non disponibili";

if (!this.gpsPosRMC.Equals("")) {
rmc = this.gpsPosRMC;
}

if (!this.gpsPosGGA.Equals("")) {
gga = this.gpsPosGGA;
}
try
{

//this.WriteInFile("&deviceId= " + this.deviceId + "&rmc= " + rmc + "&time= " + System.DateTime.Now);

// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create(url);
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "&deviceId= " + this.deviceId + "&rmc= " + rmc + "&gga= " + System.DateTime.Now;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;

// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.

dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();


}
catch (Exception e) {
this.WriteInFile("doconnect:::::"+e.Message);
//this.WriteInFile("doConnect"+e.Message);
}
}


Chiamando questo metodo riesco a contattare il server 2-3 volte poi mi si impalla generando quest'eccezione:

in System.Net.HttpWebRequest.finishGetRequestStream()
in System.Net.HttpWebRequest.GetRequestStream()
in DeviceApplication2.Form1.DoConnect()
in DeviceApplication2.Form1.button3_Click()
in System.Windows.Forms.Control.OnClick()
in System.Windows.Forms.Button.OnClick()
in System.Windows.Forms.ButtonBase.WnProc()
in System.Windows.Forms.Control._InternalWnProc()
in Microsoft.AGL.Forms.EVL.EnterMainLoop()
in System.Windows.Forms.Application.Run()
in DeviceApplication2.Program.Main()

Ho provato anche a lanciarla su windows(.exe) e funziona alla grande ma appena produco il .CAB mi funziona per 2-3 volte poi mi si impalla lanciando l'eccezione di sopra!!!!!
AIUTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Grazie anticipatamente
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5