PC Review


Reply
Thread Tools Rate Thread

deleting a subkey

 
 
aaronfude@gmail.com
Guest
Posts: n/a
 
      10th Aug 2005
Hi,

I have the following code (from a project I found on the web) that
deletes a subkey.

RegistryKey root = Registry.ClassesRoot;
root.DeleteSubKey("AllFilesystemObjects\\shellex\\ContextMenuHandlers\\CleanVS");


It throws the following exception:

Void DeleteSubKey(System.String, Boolean)
System.ArgumentException: Cannot delete a subkey tree because the
subkey does not exist.
at Microsoft.Win32.RegistryKey.DeleteSubKey(String subkey, Boolean
throwOnMis
singSubKey)
at Microsoft.Win32.RegistryKey.DeleteSubKey(String subkey)
at CleanVS.CleanVS.UnregisterServer(String zRegKey)

I checked manually that the subkey does exist, and in fact it gets
deleted during this operation! ...But I still get the error! Any
ideas?!

By the way, the key was created with this command:

root = Registry.ClassesRoot;
rk =
root.CreateSubKey("AllFilesystemObjects\\shellex\\ContextMenuHandlers\\CleanVS");
rk.SetValue("", clsid);
rk.Close();


Very many thanks in advance!

 
Reply With Quote
 
 
 
 
aaronfude@gmail.com
Guest
Posts: n/a
 
      10th Aug 2005
I'm guessing, this may not be the right news group for this question?
Can someone recommend the right news group?

Thanks!

 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      11th Aug 2005

>I'm guessing, this may not be the right news group for this question?
>Can someone recommend the right news group?


The group is fine. But I can't reproduce the problem, the key gets
deleted without any exception being thrown here. Can you put together
a short example that reproduces the problem you're seeing?



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
aaronfude@gmail.com
Guest
Posts: n/a
 
      11th Aug 2005
Hi, thanks for the answer.

Your response prompted me to put a couple of printing statements into
my method. I realized that what's happens is that the method is called
twice (which explains it).

Why it is called twice is not a mystery. Here's the excerpt from Main:

Assembly asm = Assembly.GetExecutingAssembly();
RegistrationServices reg = new RegistrationServices();
if (unregister) {
System.Console.Error.WriteLine("About to call
\"UnregisterAssemply\"");
reg.UnregisterAssembly(asm);
System.Console.Error.WriteLine("About to call \"Unregister\"");
CleanVS.UnregisterServer("");
System.Console.Error.WriteLine("Done calling \"Unregister\"");
}

and I learn that CleanVS.UnregisterServer is called automatically from
reg.UnregisterAssembly(asm) and then by me manually? Voila.

But is this defined behavior? Should I just comment out
CleanVS.UnregisterServer("")? Once again, this is not my code, but
something I found at
http://www.informit.com/articles/art...4&redir=1&rl=1

Thanks for responding and thank you very much in advance,

Aaron Fude

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem deleting registery key encluding subkey values tonyck Webmaster / Programming 3 17th Jun 2006 05:22 PM
explore.exe subkey is set to 0 =?Utf-8?B?ZnJhbms=?= Microsoft Windows 2000 1 20th Jan 2005 07:43 PM
Registry problem deleting subkey Headtheball Windows XP Help 4 20th Sep 2004 09:51 AM
API for retrival of a subkey chip Microsoft Windows 2000 Registry 1 18th Jun 2004 04:22 PM
API for retrival of a subkey chip Microsoft Windows 2000 Registry Archive 0 18th Jun 2004 10:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:01 PM.