PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework random problem connecting to GPRS programatically via OpenNetCF.Net.ConnectionManager

Reply

random problem connecting to GPRS programatically via OpenNetCF.Net.ConnectionManager

 
Thread Tools Rate Thread
Old 07-03-2007, 12:21 PM   #1
Milsnips
Guest
 
Posts: n/a
Default random problem connecting to GPRS programatically via OpenNetCF.Net.ConnectionManager


Hi there,

I am using the following module to programatically connect the user to GPRS
via my application:

----------------------
Option Explicit On
Option Strict On

Imports OpenNETCF.Net
Imports System.Net

Module GPRS

Private ConnMgr As New ConnectionManager
Private DIF As DestinationInfoCollection
Private is_connected As Boolean

ReadOnly Property isConnected() As Boolean
Get
Return is_connected
End Get
End Property

#Region "Connection Manager - Event Handlers"

'Event Handlers
Sub Connected(ByVal sender As Object, ByVal e As System.EventArgs)
is_connected = True
End Sub

'Event Handlers
Sub ConnectFailed(ByVal sender As Object, ByVal e As
System.EventArgs)
is_connected = False
MessageBox.Show("connection failed")
End Sub

'Event Handlers
Sub ConnectionWaiting(ByVal sender As Object, ByVal e As
System.EventArgs)
End Sub

'Event Handlers
Sub ConnectionDisconnect(ByVal sender As Object, ByVal e As
System.EventArgs)
is_connected = False
End Sub

#End Region

Public Sub Connect(ByVal doconnect As Boolean, ByVal connectDesc As
String)
ConnMgr = New ConnectionManager()
AddHandler ConnMgr.Connected, AddressOf Connected
AddHandler ConnMgr.ConnectionFailed, AddressOf ConnectFailed
AddHandler ConnMgr.ConnectionStateChanged, AddressOf
ConnectionWaiting
AddHandler ConnMgr.Disconnected, AddressOf ConnectionDisconnect

DIF = ConnMgr.EnumDestinations()
is_connected = False
If ConnMgr.Status.ToString() <> "Connected" Then
Try
For Each di As DestinationInfo In DIF
If Trim(LCase(di.description)) =
Trim(LCase(connectDesc)) Then
If doconnect = True Then
ConnMgr.Connect(di.guid, True,
ConnectionMode.Asynchronous)
Exit Sub
Else
Try
ConnMgr.Disconnect()
Catch ex1 As AdapterException
Log.AddLog("Error in connecting to the
internet via GPRS.Connect function")
Log.AddError(ex1)
Catch ex As Exception
Log.AddError(ex)
Finally
ConnMgr = Nothing
End Try
End If
End If
Next di
Catch err As SystemException
Log.AddError(err)
Catch ex As Exception
Log.AddError(ex)
End Try
End If
End Sub
End Module
----------------------

I use the following code to start the connection:
----------------------
Try
GPRS.Connect(True, "the internet")
Catch ex As Exception
MsgBox(ex.Message)
End Try

----------------------

On random occasions it will decide that it just doesnt want to connect, and
i dont know why, because when i start IE and browse a site, GPRS starts
connecting just fine.

Any help appreciated,
thanks,
Paul


  Reply With Quote
Old 07-03-2007, 01:32 PM   #2
=?Utf-8?B?U2ltb24gSGFydA==?=
Guest
 
Posts: n/a
Default RE: random problem connecting to GPRS programatically via OpenNetCF.Ne

What OS is this as I have found pre WM 5 the Connection Manager is a little
flakey.

Simon.

"Milsnips" wrote:

> Hi there,
>
> I am using the following module to programatically connect the user to GPRS
> via my application:
>
> ----------------------
> Option Explicit On
> Option Strict On
>
> Imports OpenNETCF.Net
> Imports System.Net
>
> Module GPRS
>
> Private ConnMgr As New ConnectionManager
> Private DIF As DestinationInfoCollection
> Private is_connected As Boolean
>
> ReadOnly Property isConnected() As Boolean
> Get
> Return is_connected
> End Get
> End Property
>
> #Region "Connection Manager - Event Handlers"
>
> 'Event Handlers
> Sub Connected(ByVal sender As Object, ByVal e As System.EventArgs)
> is_connected = True
> End Sub
>
> 'Event Handlers
> Sub ConnectFailed(ByVal sender As Object, ByVal e As
> System.EventArgs)
> is_connected = False
> MessageBox.Show("connection failed")
> End Sub
>
> 'Event Handlers
> Sub ConnectionWaiting(ByVal sender As Object, ByVal e As
> System.EventArgs)
> End Sub
>
> 'Event Handlers
> Sub ConnectionDisconnect(ByVal sender As Object, ByVal e As
> System.EventArgs)
> is_connected = False
> End Sub
>
> #End Region
>
> Public Sub Connect(ByVal doconnect As Boolean, ByVal connectDesc As
> String)
> ConnMgr = New ConnectionManager()
> AddHandler ConnMgr.Connected, AddressOf Connected
> AddHandler ConnMgr.ConnectionFailed, AddressOf ConnectFailed
> AddHandler ConnMgr.ConnectionStateChanged, AddressOf
> ConnectionWaiting
> AddHandler ConnMgr.Disconnected, AddressOf ConnectionDisconnect
>
> DIF = ConnMgr.EnumDestinations()
> is_connected = False
> If ConnMgr.Status.ToString() <> "Connected" Then
> Try
> For Each di As DestinationInfo In DIF
> If Trim(LCase(di.description)) =
> Trim(LCase(connectDesc)) Then
> If doconnect = True Then
> ConnMgr.Connect(di.guid, True,
> ConnectionMode.Asynchronous)
> Exit Sub
> Else
> Try
> ConnMgr.Disconnect()
> Catch ex1 As AdapterException
> Log.AddLog("Error in connecting to the
> internet via GPRS.Connect function")
> Log.AddError(ex1)
> Catch ex As Exception
> Log.AddError(ex)
> Finally
> ConnMgr = Nothing
> End Try
> End If
> End If
> Next di
> Catch err As SystemException
> Log.AddError(err)
> Catch ex As Exception
> Log.AddError(ex)
> End Try
> End If
> End Sub
> End Module
> ----------------------
>
> I use the following code to start the connection:
> ----------------------
> Try
> GPRS.Connect(True, "the internet")
> Catch ex As Exception
> MsgBox(ex.Message)
> End Try
>
> ----------------------
>
> On random occasions it will decide that it just doesnt want to connect, and
> i dont know why, because when i start IE and browse a site, GPRS starts
> connecting just fine.
>
> Any help appreciated,
> thanks,
> Paul
>
>
>

  Reply With Quote
Old 07-03-2007, 01:48 PM   #3
Milsnips
Guest
 
Posts: n/a
Default Re: random problem connecting to GPRS programatically via OpenNetCF.Net

Hi Simon,

I'm using Windows Mobile 5 (O.S 5.1.195 build 14847.2.0.0)

regards,
paul
"Simon Hart" <srhartone@yahoo.com> wrote in message
news:1998DF69-3DFC-414B-8E0C-24EB44273A53@microsoft.com...
> What OS is this as I have found pre WM 5 the Connection Manager is a
> little
> flakey.
>
> Simon.
>
> "Milsnips" wrote:
>
>> Hi there,
>>
>> I am using the following module to programatically connect the user to
>> GPRS
>> via my application:
>>
>> ----------------------
>> Option Explicit On
>> Option Strict On
>>
>> Imports OpenNETCF.Net
>> Imports System.Net
>>
>> Module GPRS
>>
>> Private ConnMgr As New ConnectionManager
>> Private DIF As DestinationInfoCollection
>> Private is_connected As Boolean
>>
>> ReadOnly Property isConnected() As Boolean
>> Get
>> Return is_connected
>> End Get
>> End Property
>>
>> #Region "Connection Manager - Event Handlers"
>>
>> 'Event Handlers
>> Sub Connected(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>> is_connected = True
>> End Sub
>>
>> 'Event Handlers
>> Sub ConnectFailed(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>> is_connected = False
>> MessageBox.Show("connection failed")
>> End Sub
>>
>> 'Event Handlers
>> Sub ConnectionWaiting(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>> End Sub
>>
>> 'Event Handlers
>> Sub ConnectionDisconnect(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>> is_connected = False
>> End Sub
>>
>> #End Region
>>
>> Public Sub Connect(ByVal doconnect As Boolean, ByVal connectDesc
>> As
>> String)
>> ConnMgr = New ConnectionManager()
>> AddHandler ConnMgr.Connected, AddressOf Connected
>> AddHandler ConnMgr.ConnectionFailed, AddressOf ConnectFailed
>> AddHandler ConnMgr.ConnectionStateChanged, AddressOf
>> ConnectionWaiting
>> AddHandler ConnMgr.Disconnected, AddressOf
>> ConnectionDisconnect
>>
>> DIF = ConnMgr.EnumDestinations()
>> is_connected = False
>> If ConnMgr.Status.ToString() <> "Connected" Then
>> Try
>> For Each di As DestinationInfo In DIF
>> If Trim(LCase(di.description)) =
>> Trim(LCase(connectDesc)) Then
>> If doconnect = True Then
>> ConnMgr.Connect(di.guid, True,
>> ConnectionMode.Asynchronous)
>> Exit Sub
>> Else
>> Try
>> ConnMgr.Disconnect()
>> Catch ex1 As AdapterException
>> Log.AddLog("Error in connecting to
>> the
>> internet via GPRS.Connect function")
>> Log.AddError(ex1)
>> Catch ex As Exception
>> Log.AddError(ex)
>> Finally
>> ConnMgr = Nothing
>> End Try
>> End If
>> End If
>> Next di
>> Catch err As SystemException
>> Log.AddError(err)
>> Catch ex As Exception
>> Log.AddError(ex)
>> End Try
>> End If
>> End Sub
>> End Module
>> ----------------------
>>
>> I use the following code to start the connection:
>> ----------------------
>> Try
>> GPRS.Connect(True, "the internet")
>> Catch ex As Exception
>> MsgBox(ex.Message)
>> End Try
>>
>> ----------------------
>>
>> On random occasions it will decide that it just doesnt want to connect,
>> and
>> i dont know why, because when i start IE and browse a site, GPRS starts
>> connecting just fine.
>>
>> Any help appreciated,
>> thanks,
>> Paul
>>
>>
>>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off