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
Delegate Sub Callback(ByVal unMsg As Integer, ByVal rasconnstate As
Integer, ByVal dwError As Integer)
------------
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."
>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.
You are right, but it still doesnt solve the mystery why rasdial fails
to dial when the delegate is used.
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