Sample Code not working

Sep 24, 2011 at 9:08 PM

I opened the SDK in Visual Studio 2010 and tried to run the CreateAndDialVpnEntry solution. The following problems occurred:

1) The CreateEntry failed as the phonebook could not be found. The detected path is incorrect. There does not seem to be a way to set the path as Me.AllUsersPhoneBook.Path is read only.

2) The Dialler also failed because the phonebook path was incorrect. I manually set the path to:

Me.Dialer.PhoneBookPath = C:\Users\<UserName>\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk.

This enable the dialler to dial to the connection.

3) Hanging up the connection failed because the Me.connectionHandle is null. So far I have not been able to resolve this.

Can anyone provide a working example of how to use DotRas in Visual Studio 2010, Framework 4.0?

Coordinator
Sep 24, 2011 at 10:22 PM

1) The CreateEntry failed as the phonebook could not be found. The detected path is incorrect. There does not seem to be a way to set the path as Me.AllUsersPhoneBook.Path is read only.

Yes the path property is read-only; it's determined when the Open method is called on the instance. That sets up all the underlying pieces that the RasPhoneBook class uses to that particular path. As indicated by comments within the example along within the SDK help files, the overloads called by Open determines where it's being opened at. If your machine where you ran the example at didn't have the All Users profile phonebook already, or if you couldn't modify it I have no doubt it'd cause problems.

2) The Dialler also failed because the phonebook path was incorrect. I manually set the path to:

Again, the Open overload that the phonebook was using is in the All Users profile, not the current user profile. So the dialer must be pointed at the same path to find the entry that it was going to create, otherwise dialing a connection when the entry is in another phonebook on the machine would have caused another problem.

There are multiple files in use by Windows for phonebooks since they're file based and no longer stored in the registry.

3) Hanging up the connection failed because the Me.connectionHandle is null. So far I have not been able to resolve this.

That was a minor bug in the VB example, already fixed it and checked it in for the next release. You just need to change line 33 to: Me.connectionHandle = Me.Dialer.DialAsync()

- Jeff

Sep 25, 2011 at 8:22 AM
Edited Sep 25, 2011 at 9:20 AM

Thanks Jeff

I fixed line 33. Now I find the following errors with the demo app:

1) While the modem did disconnect once, no DialerStateChanged event was fired.

2) If the modem is connected and I then click on the connect button, it displays the message "Connected" and "Connection Successful" (but only once). When I click to disconnect, the application hangs.

3) Since the handle is only created within the application, not knowing the prior state of the modem interface (which might be connected before the application start), I then tried to get the connection using Dim connection As RasConnection = RasConnection.GetActiveConnectionByName(EntryName, Me.Dialer.PhoneBookPath). While connection was not null, the instruction connection.HangUp() did not hang up the connection. Instead, it hung up the application as previous.

Please assist.

All I am trying to do is a simple auto dial function (no user interaction) for maintaining a connection. I want to:

1) Determine if a connection has already been established on a modem. If not, dial the connection.

2) Maintain the connection - if it drops, dial it again. Question: if the Phonebook entry is set to maintain a connection, how does that impact the above?

3) Close the connection

I see there is also a RasAutodialManager Class. What is the difference between that and the RasDialler class? 

Regards

Coordinator
Sep 26, 2011 at 3:41 AM

1) While the modem did disconnect once, no DialerStateChanged event was fired.

As stated within the documentation the RasDialer StateChanged event is only raised during a dialing operation, if you call HangUp it would never be raised because it's not happening during a dialing operation.

2) If the modem is connected and I then click on the connect button, it displays the message "Connected" and "Connection Successful" (but only once). When I click to disconnect, the application hangs.

This is an example intended to show basic usage of the API, it was never designed to be able to handle every circumstance thrown at it by connecting or disconnecting the connection outside of the control of the example application. It is merely a tool to demonstrate how DotRas could be used to establish a connection after creating an entry. Your application requirements will need to determine what must be done to handle the scenarios you wish to handle within your application.

3) Since the handle is only created within the application, not knowing the prior state of the modem interface (which might be connected before the application start), I then tried to get the connection using Dim connection As RasConnection = RasConnection.GetActiveConnectionByName(EntryName, Me.Dialer.PhoneBookPath). While connection was not null, the instruction connection.HangUp() did not hang up the connection. Instead, it hung up the application as previous.

See previous answer.

As for your statements about what you wanted to build, you'll need to spend the time testing how each scenario could impact your application. Those are app specific requirements and are considered out of scope for this project.

I see there is also a RasAutodialManager Class. What is the difference between that and the RasDialler class?

As stated in the SDK documentation it's a used for interacting with the RAS AutoDial database, the RasDialer class is used to dial a connection.

Since you seem to be asking many questions that are already covered within the documentation, consider this your notice that any future questions that could have been answered by spending a little time reading the documentation will no longer be answered. It's not my intention to be rude, but it gets frustrating answering the same questions repeatedly when people don't read the docs. This discussion forum also has quite a bit of questions that have been asked and answered over the years and is a valuable resource to check before asking a question.

Sep 26, 2011 at 6:51 AM

Jeff, please find my comments coming from an experienced programmer who is also using other third party API's

1) I did study your documentation, which I find cryptic at best, with one line sentences. There is no proper overview of what class does what. 

2) The Getting Started covers features and benefits. It does not tell you what class does what or how to use it - or where to start

3) There are no examples in the documentation. With such cryptic documentation you can expect support questions

4) As indicated, the VPN example tested hangs. You could also not provide any details of how to prevent DotRas from hanging - it does so without generating any exceptions or error events. There are NO details in the documentation indicating how to resolve this.

I find your attitude in answering my questions to be arrogant and unsupportive as I have given your the simple scenario of what I was attempting to do. There are NO answers on how to do that scenario in your documentation.

I have therefore decided not to use DotRas, until the above issues have been clarified.

Coordinator
Sep 26, 2011 at 1:16 PM

Well that's your decision to make, good luck with your project.

- Jeff