Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems with RasDial (rasapi32.dll)

26 views
Skip to first unread message

Les Hughes

unread,
Sep 27, 2004, 9:10:27 AM9/27/04
to

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

According to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rras/rras/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

Les Hughes

unread,
Sep 27, 2004, 9:15:52 AM9/27/04
to
Some relevant code I left out...

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

Integer, ByVal dwError As Integer)

Les Hughes

unread,
Sep 27, 2004, 9:41:37 AM9/27/04
to

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

unread,
Sep 27, 2004, 10:51:40 AM9/27/04
to

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

Mattias Sjögren

unread,
Sep 27, 2004, 5:18:04 PM9/27/04
to
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.

Les Hughes

unread,
Sep 28, 2004, 3:54:14 AM9/28/04
to

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

jwinn

unread,
Feb 1, 2005, 11:51:01 PM2/1/05
to
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/Workspace.aspx?id=dd3ebd3e-684a-4dde-a843-e5fdb0895b8e

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

0 new messages