Exception while parsing phonebook entry collection

Feb 16, 2010 at 10:04 PM

Hi,

The following code:

        publicPhonebook = New RasPhoneBook

        publicPhonebook.Open()

        For Each entry As RasEntry In publicPhonebook.Entries

            If entry.Name.Equals(connectionName, StringComparison.CurrentCultureIgnoreCase) Then

                foundIt = True

                Exit For

            End If

        Next

 

throws this exception:

 

 

System.ArgumentException: 'name' cannot be a null reference or empty string.
Parameter name: name
   at DotRas.ThrowHelper.ThrowArgumentException(String argumentName, String resource, Object[] args)
   at DotRas.RasDevice.Create(String name, String deviceType)
   at DotRas.RasHelper.GetEntryProperties(RasPhoneBook phoneBook, String entryName)
   at DotRas.RasEntryCollection.Load()
   at DotRas.RasPhoneBook.Open(String phoneBookPath)
   at DotRas.RasPhoneBook.Open(Boolean openUserPhoneBook)
   at DotRas.RasPhoneBook.Open()

System.ArgumentException: 'name' cannot be a null reference or empty string.

Parameter name: name

   at DotRas.ThrowHelper.ThrowArgumentException(String argumentName, String resource, Object[] args)

   at DotRas.RasDevice.Create(String name, String deviceType)

   at DotRas.RasHelper.GetEntryProperties(RasPhoneBook phoneBook, String entryName)

   at DotRas.RasEntryCollection.Load()

   at DotRas.RasPhoneBook.Open(String phoneBookPath)

   at DotRas.RasPhoneBook.Open(Boolean openUserPhoneBook)

   at DotRas.RasPhoneBook.Open()

 

The connection I am searching for is a direct cable connection which uses the 'Communications cable between two computers' device. The device exists and it is working. The exception is occurring on a production machine so I am unable to debug in Visual Studio.

Looking at the DotRas source, I am assuming the exception is occurring on this line in the RasHelper.GetEntryProperties function, and the deviceName is empty:

retval.Device = RasDevice.Create(entry.deviceName, entry.deviceType);

Any help would be appreciated.

 

 

 

 

Coordinator
Feb 17, 2010 at 3:06 AM

Is the device name null or is it an empty string? There is a known bug with 1.1 that I attempted to fix for the 1.2 release that only populates the device while loading entries if the device name is not null and the device type is not null or empty. If the device name is supposed to be null I'll need to pull that check off the device.

- Jeff

Feb 17, 2010 at 3:22 AM

Hi Jeff

I am unable to debug so I can't tell you what the deviceName property actually is. However, the devices in my phonebook are all valid and have names.

I have since narrowed down the point at which the exception occurs. It happens when the phonebook is opened, not when parsing the collection.

 

 

 

 

 

 

 

Coordinator
Feb 17, 2010 at 1:51 PM

Yeah I saw when it's happening from the stack trace you posted earlier. Try getting latest from source control and building the project yourself, it may fix your issue. Just run the make.bat at the root of trunk when you do, though you may have to edit the start of the batch file to build it, there are some booleans in it to turn on/off what happens during the build. You probably won't have all the tools necessary to do a full build, all you need is the binaries anyway.

Feb 18, 2010 at 12:15 AM

Jeff,

I'm not sure I'll go as far as rebuilding the source this time around. I've worked around it by improving the error handling when the phonebook is opened so the error gets logged but the app continues on happily. Exception is still occurring but now my application is working fine.

Thanks 

Mar 14, 2010 at 9:25 PM

Hi,

I've had (well actually have) the same problem after upgrading Windows Messenger and having it create a MSN connection entry in Network connections. I couldn't see the properties of this connection but it seems that it doesn't have a device name. After I've deleted it, everything works fine again...

@Jeff Thanks for a great project!