0

I'm hunting a problem regarding a DLL loading problem: How to determine source of .net dll loading problem

Now, I mentioned, that that the registry access of C# programs fails. To test this, I made a minimal test program:

   class Program
    {
        static void GetTestKey(String Key)
        {
            //Console.WriteLine(Key);
            try
            {
                RegistryKey key = Registry.ClassesRoot.OpenSubKey(Key, false);
                if (key == null)
                {
                    Console.WriteLine("Could not open: " + Key);
                    return;
                }
                foreach (String s in key.GetSubKeyNames())
                {
                    GetTestKey(Key + @"\" + s);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + Key + ": " + e);
                Thread.Sleep(1000);
            }
        }

        static void Main(string[] args)
        {
            GetTestKey("");
            Console.WriteLine("Ende");
            Console.ReadLine();
        }

Result:

Could not open: \*\shellex\ContextMenuHandlers\ FileSyncEx
Could not open: \.3fr\OpenWithProgids
Could not open: \.3mf\OpenWithProgids
Could not open: \.ac3\OpenWithProgids
Could not open: \.all
Could not open: \.amr
Could not open: \.appinstaller
Could not open: \.appx
Could not open: \.appxbundle
Could not open: \.ari\OpenWithProgids
Could not open: \.arw\OpenWithProgids
Could not open: \.ass
[...]

So, every fifth to tenth key is not accessible (key == null). I've permissions on all keys. And the permissions they seems to be inherited! There is no "deny" permission.

Why is the key == null? MSDN: On error the return is null. How to get the error?

Additional: I have "change" permissions at this keys (I'm wounding why, this is a company computer. But I have got the permissions!). Changing the access to "writable = true" leads to "System.Security.SecurityException" on every access.

ATM I believe, that there is another security level, I did not know (yet).

Any help? Hints?

Ralph Erdt
  • 537
  • 4
  • 16
  • Did you run it with [admin rights](https://stackoverflow.com/q/2818179/1997232)? – Sinatr Aug 05 '21 at 14:16
  • I've tested it with my user account. Oh. Run as Administrator: Same. Why? – Ralph Erdt Aug 06 '21 at 05:25
  • Another day, another view. "GetTestKey(Reg, Key != "" ? Key + @"\" + s : s);" and this works. Seems, the Registry Access isn't able to handle a key starting with "\" at all time. – Ralph Erdt Aug 06 '21 at 05:33

0 Answers0