By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,550 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,550 IT Pros & Developers. It's quick & easy.

Problems with RasDial (rasapi32.dll)

P: n/a

Im working on some RAS stuff, and am after callbacks for when the
connection is disconnected.

According to
http://msdn.microsoft.com/library/de...as/rasdial.asp
If I dial using

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)
all will be well, but when this is used, it seems that the modem does
not dial at all, although a sucessful connection message is returned.

RasDial(Nothing, Nothing, cRasDialParams, Nothing, Nothing, handle)
will make the modem dial, and sucessfully work.

The revelant code is:

<DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function RasDial(ByVal lpRasDialExtensions As
Integer, ByVal lpszPhonebook As String, ByRef lprasdialparams As
_RASDIALPARAMS, ByVal dwNotifierType As Integer, ByVal lpvNotifier As
Callback, ByRef lphRasConn As Integer) As Integer
End Function

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)

Public Shared Sub RasDialFunc(ByVal unMsg As Integer, ByVal rasconnstate
As Integer, ByVal dwError As Integer)
Debug.WriteLine("DF: " & unMsg.ToString & " - " &
rasconnstate.ToString & " - " & dwError.ToString)

If Not dwError.ToString = "0" Then
Debug.WriteLine("Error: " & dwError)
End If

End Sub
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Some relevant code I left out...

Delegate Sub Callback(ByVal unMsg As Integer, ByVal rasconnstate As
Integer, ByVal dwError As Integer)


Les Hughes wrote:

Im working on some RAS stuff, and am after callbacks for when the
connection is disconnected.

According to
http://msdn.microsoft.com/library/de...as/rasdial.asp

If I dial using

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)
all will be well, but when this is used, it seems that the modem does
not dial at all, although a sucessful connection message is returned.

RasDial(Nothing, Nothing, cRasDialParams, Nothing, Nothing, handle)
will make the modem dial, and sucessfully work.

The revelant code is:

<DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function RasDial(ByVal lpRasDialExtensions As
Integer, ByVal lpszPhonebook As String, ByRef lprasdialparams As
_RASDIALPARAMS, ByVal dwNotifierType As Integer, ByVal lpvNotifier As
Callback, ByRef lphRasConn As Integer) As Integer
End Function

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)

Public Shared Sub RasDialFunc(ByVal unMsg As Integer, ByVal rasconnstate
As Integer, ByVal dwError As Integer)
Debug.WriteLine("DF: " & unMsg.ToString & " - " &
rasconnstate.ToString & " - " & dwError.ToString)

If Not dwError.ToString = "0" Then
Debug.WriteLine("Error: " & dwError)
End If

End Sub

Nov 21 '05 #2

P: n/a

Every now and then I also get these errors:

------------
An unhandled exception of type 'System.NullReferenceException' occurred
in Unknown Module.

Additional information: Object reference not set to an instance of an
object.
-----------

then

"There is no source code available for the current location."

Les Hughes wrote:
Some relevant code I left out...

Delegate Sub Callback(ByVal unMsg As Integer, ByVal rasconnstate As
Integer, ByVal dwError As Integer)


Les Hughes wrote:

Im working on some RAS stuff, and am after callbacks for when the
connection is disconnected.

According to
http://msdn.microsoft.com/library/de...as/rasdial.asp

If I dial using

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc,
handle)
all will be well, but when this is used, it seems that the modem does
not dial at all, although a sucessful connection message is returned.

RasDial(Nothing, Nothing, cRasDialParams, Nothing, Nothing, handle)
will make the modem dial, and sucessfully work.

The revelant code is:

<DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function RasDial(ByVal lpRasDialExtensions As
Integer, ByVal lpszPhonebook As String, ByRef lprasdialparams As
_RASDIALPARAMS, ByVal dwNotifierType As Integer, ByVal lpvNotifier As
Callback, ByRef lphRasConn As Integer) As Integer
End Function

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc,
handle)

Public Shared Sub RasDialFunc(ByVal unMsg As Integer, ByVal
rasconnstate As Integer, ByVal dwError As Integer)
Debug.WriteLine("DF: " & unMsg.ToString & " - " &
rasconnstate.ToString & " - " & dwError.ToString)

If Not dwError.ToString = "0" Then
Debug.WriteLine("Error: " & dwError)
End If

End Sub

Nov 21 '05 #3

P: n/a

Does anyone have any useful links on this topic? Ive been searching for
about 4½ hours for a solution, argh!

Les Hughes wrote:

Im working on some RAS stuff, and am after callbacks for when the
connection is disconnected.

According to
http://msdn.microsoft.com/library/de...as/rasdial.asp

If I dial using

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)
all will be well, but when this is used, it seems that the modem does
not dial at all, although a sucessful connection message is returned.

RasDial(Nothing, Nothing, cRasDialParams, Nothing, Nothing, handle)
will make the modem dial, and sucessfully work.

The revelant code is:

<DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function RasDial(ByVal lpRasDialExtensions As
Integer, ByVal lpszPhonebook As String, ByRef lprasdialparams As
_RASDIALPARAMS, ByVal dwNotifierType As Integer, ByVal lpvNotifier As
Callback, ByRef lphRasConn As Integer) As Integer
End Function

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)

Public Shared Sub RasDialFunc(ByVal unMsg As Integer, ByVal rasconnstate
As Integer, ByVal dwError As Integer)
Debug.WriteLine("DF: " & unMsg.ToString & " - " &
rasconnstate.ToString & " - " & dwError.ToString)

If Not dwError.ToString = "0" Then
Debug.WriteLine("Error: " & dwError)
End If

End Sub

Nov 21 '05 #4

P: n/a
Les,
Every now and then I also get these errors:

------------
An unhandled exception of type 'System.NullReferenceException' occurred
in Unknown Module.

Additional information: Object reference not set to an instance of an
object.
-----------

You should hold on to a reference to the callback delegate you pass in
to the function, or it may get garbage collected and invalidate the
native function pointer.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #5

P: n/a


You are right, but it still doesnt solve the mystery why rasdial fails
to dial when the delegate is used.

Mattias Sjögren wrote:
Les,

Every now and then I also get these errors:

------------
An unhandled exception of type 'System.NullReferenceException' occurred
in Unknown Module.

Additional information: Object reference not set to an instance of an
object.
-----------


You should hold on to a reference to the callback delegate you pass in
to the function, or it may get garbage collected and invalidate the
native function pointer.

Mattias

Nov 21 '05 #6

P: n/a
I just finished creating a RAS wrapper for .NET with (hopefully) all RAS
functionality built in for outgoing connections. It can be found at:

http://www.gotdotnet.com/Workspaces/...3-e5fdb0895b8e

If you find any bugs with it, please report them so they can be addressed.
Thanks

"Les Hughes" wrote:

Im working on some RAS stuff, and am after callbacks for when the
connection is disconnected.

According to
http://msdn.microsoft.com/library/de...as/rasdial.asp
If I dial using

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)
all will be well, but when this is used, it seems that the modem does
not dial at all, although a sucessful connection message is returned.

RasDial(Nothing, Nothing, cRasDialParams, Nothing, Nothing, handle)
will make the modem dial, and sucessfully work.

The revelant code is:

<DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function RasDial(ByVal lpRasDialExtensions As
Integer, ByVal lpszPhonebook As String, ByRef lprasdialparams As
_RASDIALPARAMS, ByVal dwNotifierType As Integer, ByVal lpvNotifier As
Callback, ByRef lphRasConn As Integer) As Integer
End Function

RasDial(Nothing, Nothing, cRasDialParams, 0, AddressOf RasDialFunc, handle)

Public Shared Sub RasDialFunc(ByVal unMsg As Integer, ByVal rasconnstate
As Integer, ByVal dwError As Integer)
Debug.WriteLine("DF: " & unMsg.ToString & " - " &
rasconnstate.ToString & " - " & dwError.ToString)

If Not dwError.ToString = "0" Then
Debug.WriteLine("Error: " & dwError)
End If

End Sub

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.