Opennetcf DeleteSubKey "bug"?

J

James Caan

Hello

I have problem deleting a subkey which I've create some seconds before:

Dim x As OpenNETCF.Win32.RegistryKey
x = OpenNETCF.Win32.Registry.LocalMachine.OpenSubKey("Software")
x.CreateSubKey("Test")
System.Threading.Thread.Sleep(10000)
x.DeleteSubKey("Test")

This is throwing an error "The specified subkey is not a valid reference to
a registry key"

The interesting thing is, if I wait several minutes, I can delete the
subkey...

Why?

Thanks

James
 
G

Guest

A few things:

1. You might log this as a bug in our issue database
(bugzilla.opennetcf.com) - probably far greater chance of support if it's
there.

2. If you open the key with more that read access does the behavior change?

3. If you flush the key before delete does the behavior change?

4. What kind of device is this? Does it have a hive-based registry?


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
J

James Caan

Hi and thanks for your reply

I have now the following code:

Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem1.Click
Dim y As OpenNETCF.Win32.RegistryKey
y = OpenNETCF.Win32.Registry.LocalMachine.OpenSubKey("Software",
True)
y.DeleteSubKey("Test")
y.Flush()
y.Close()
MsgBox("Done")
End Sub

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem2.Click
Dim x As OpenNETCF.Win32.RegistryKey
x = OpenNETCF.Win32.Registry.LocalMachine.OpenSubKey("Software",
True)
x.CreateSubKey("Test")
x.Flush()
x.Close()
MsgBox("Done")
End Sub

The interesting thing is: If I use MenuItem2_Click to create the subkey, and
then MenuItem1_Click to delete it, I get the error message. But if I close
my application after creating the SubKey, and then restart it and directly
use MenuItem1_Click, it is deleting the Subkey without any problems...

Devices ar HTC Artemis and HTC Universal, both with WM 5.0
 
J

James Caan

Btw. Setting Writeable to True while opening the Key doesnt solve the
problem...
 
G

Guest

You might want to reconsider the OpenNETCF key stuff and just use the
Microsoft.Win32 Registry classes directly. There are some good examples of
their use on MSDN, and you reduce all of the OpenNetCF overhead.

Rick D.
Contractor
 
G

Guest

A good idea if you're on CF 2.0. If you're using CF 1.0 then the registry
stuff isn't there.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top