OpenNetCF Communications - Possible Bug?

  • Thread starter Thread starter Paul [Paradise Solutions]
  • Start date Start date
P

Paul [Paradise Solutions]

Hi there

I would have posted this in the OpenNetCF forums, but for some reason I
can't register and I need to get this question asked.

I'm using the Communications DLL (and top stuff it is too) but I'm
getting a slight problem with opening a registry key on the PDA from the
desktop.
Using OpenSubKey, Ims attempting to access the key:
Software\BAC\PDASales

But the call is returning an error saying "The length of the specified
subkey is longer than the maximum amount (255)"

I've put the code I'm using at the end, and it's running inside a form.

Many thanks for your assistance



Paul




Try
'// connect to PDA via rapi
p_Rapi.Connect()

'// show state
StatusBar1.Text = "Loading Generic PDA data..."

'// Get device name
p_RegKey = p_Reg.LocalMachine.OpenSubKey("Ident")
lblDeviceName.Text = p_RegKey.GetValue("Name")
p_RegKey.Close()

'// get sync list
p_RegKey = p_Reg.LocalMachine.OpenSubKey("Software\BAC")
MessageBox.Show(p_RegKey.SubKeyCount.ToString)

Dim SubKeys() As String
Dim SubKeyCounter As Int16
Dim SubKeyMax As Int16

'// Get sub keys from BAC
SubKeys = p_RegKey.GetSubKeyNames()
p_RegKey.Close()

SubKeyMax = SubKeys.Length - 1

'// Loop through subkeys checking for "sync" value
For SubKeyCounter = 0 To SubKeyMax

'MessageBox.Show(SubKeys(SubKeyCounter))

'***Blows up here****
p_RegKey = p_Reg.LocalMachine.OpenSubKey("Software\BAC\PDASales")

Try
MessageBox.Show(p_RegKey.GetValue("Sync"))

Catch ex As Exception
MessageBox.Show("Element " + SubKeys(SubKeyCounter) + " had
no " _ "sync setting")

End Try

p_RegKey.Close()

Application.DoEvents()

Next

Catch ex As Exception
MessageBox.Show(ex.Message)

Finally
'// Ensure disconnect
If p_Rapi.Connected Then
p_Rapi.Disconnect()
End If

End Try
 
Looking at your source and the Communications source ti doesn't make sense.
The call returning false for this comparison in OpenSubKey(string name, bool
writable):

if(name.Length < 256)
{
...
}

I don't have the time right now to look further, but I suggest stepping into
the code to see why that comparison is failing.
 
Thanks for your reply - had a go at the debugging, but I don't really
know how to drive C# and I didn't really get anywhere (was either
complaining about no symbols or a compile switch about '/unsafe' code).
Anyway, I'll have to wait for you or see if anyone else can look for me.

Once again, many thanks.


Paul
 
Post the smallest application you can build which exhibits the problem.
This will allow the person working on it to just do the debugging and not
have to build a superstructure in which to try that. If you put everything,
including the solution files, etc., in a ZIP file, it's pretty easy to go
from there...

Paul T.
 
I thought this was a no attachment NG... or am I being dim over something?

To the problem in hand, I think I've found the problem.

All elements in the array returned by GetSubKeyNames have lengths of 256
(which I didn't notice before now) - I assume these are buffer nulls.
Appologies if this is documented behaviour and I missed it - will just
chop 'em off.


Ta all.


Paul
 
No, you can attach things with no problem that I've seen. I'm not sure if
it's documented in detail or not, but it should be, if not, obviously.

Paul T.
 
It's kind of a sad state of affairs when a group of non-profit people
put more effort and dedication into to software than some companies....
but I'm glad you do!
 
Back
Top