Error trying to get CommPort discovery working

Discussion in 'Questions (Windows Mobile)' started by djmrozinski, Apr 6, 2008.

  1. djmrozinski

    djmrozinski Member Licensed User

    Hello,

    I have been playing with the ComPort.shp file has is posted in the forum. It is designed to allow you to gather ComPort information. Very nice code, but I am having one little problem.

    Everything works except then "FriendlyName" value.

    When the code tries to execute the Reg.GetValue(key,"FriendlyName") I get an error that say something about Iconvertible.

    Search the forum with no success. Anyone else had any luck.

    Thanks
    Dave
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. djmrozinski

    djmrozinski Member Licensed User

    I just installed Basic4PPC in March, so I have the new versions on the device.

    Any other suggestions.

    Thanks
    Dave
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Please copy the attached executable and library to the device.
    Try to run the executable and see if it works.
     

    Attached Files:

  5. djmrozinski

    djmrozinski Member Licensed User

    still getting the same error.

    "Object must implement IConvertible. Continue?"

    RegistryDevice.dll Version 1.0.2911.26229
    SerialDevice.dll (one you sent)

    I'm using Serial2.dll with my application

    Thanks for the help
    Dave
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Sorry, I've attached the wrong library. It should have been RegistryDevice.dll not SerialDevice.dll
    The zip file is now updated.
    The most updated RegistryDevice.dll was modified on 12/21/2007.
    Please make sure that you are using it.
    Please add the following line before the problematic line and see if it returns a Null value.
    Code:
    Msgbox(IsNull(reg.GetValue(key,"FriendlyName")))
     
  7. djmrozinski

    djmrozinski Member Licensed User

    Erel,

    I inserted the line of code you suggested and played around a little bit. I have determined that when the program get to COM2: Drivers\BuiltIn\IrDa and then moves to the code to get the "FriendlyName" the error is generated.

    Does give you any clue. I am really stumpped.

    Thanks for all the help
    Dave
     
  8. alfcen

    alfcen Well-Known Member Licensed User

    Hi,
    I am seeing the same error.

    The error does not show up under the old compiler
    and there is no error either when compiled optimized and running under WM6.

    Error condition, as far as I observed: optimized compiled and PPC 2003.
    It must be related to the conversion of the "FriendlyName" key/data.
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Please try to use GetString instead:
    Code:
    If Not(IsNull(Reg.GetValue(key,"FriendlyName"))) Then
        al1.Add(name & 
    ": " & reg.GetString(key,"FriendlyName"))
    End If
     
  10. alfcen

    alfcen Well-Known Member Licensed User

    Trying to narrow down:

    If a value does not exist, GetString returns NullException error, while GetValue returns that IConvertable message (optimized compiler and PPC 2003). Assumingly, the got value can't be converted to a string.

    According to Registry Help, both can be used to get REG_SZ values.

    Instead of NullException, GetString should ideally return an empty string.
    Catching up NullExceptions while quering registry entries in a For...Next loop is not feasable.

    There are no such issues with the old compiler or optimized compiled running under WM5/6.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Do you get this error with the code in my previous post?
     
  12. alfcen

    alfcen Well-Known Member Licensed User

    Yes, I do, Erel
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    I will update the Registry library so GetString will handle null values properly.
     
  14. alfcen

    alfcen Well-Known Member Licensed User

    Sounds like music :)
     
  15. djmrozinski

    djmrozinski Member Licensed User

    Hello,

    I got the same error as well. You also suggested Reg.GetObject, I don't see that support in the help file. Was that correct?

    Thanks and keep me updated.

    Dave
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    :signOops: Please try the following code:
    Code:
    If Not(IsNull(Reg.GetValue(key,"FriendlyName"))) Then
        al1.Add(name & 
    ": " & reg.GetString(key,"FriendlyName"))
    End If
     
  17. djmrozinski

    djmrozinski Member Licensed User

    I assumed the Reg.GetObject should be Reg.GetValue It still gave the same error.

    Thanks again for all the help.

    Dave
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    I've attached an update to RegistryDevice.dll that should return an empty string instead of null values.
    Please test your application with it.
     

    Attached Files:

  19. alfcen

    alfcen Well-Known Member Licensed User

    Lovely, Erel, performs like a charm.
    Your responsiveness to support issues and your expertise are out of this world!
     
Loading...