Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

deleting a subkey

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aaronfude@gmail.com - 10 Aug 2005 01:01 GMT
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!
aaronfude@gmail.com - 10 Aug 2005 20:11 GMT
I'm guessing, this may not be the right news group for this question?
Can someone recommend the right news group?

Thanks!
Mattias Sjögren - 11 Aug 2005 08:01 GMT
>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

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

aaronfude@gmail.com - 11 Aug 2005 16:24 GMT
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/article.asp?p=169474&redir=1&rl=1

Thanks for responding and thank you very much in advance,

Aaron Fude

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.