0

I added a registry key value from c#.Net:

            using Microsoft.Win32;
            string REGISTRY_PATH = @"SOFTWARE\Microsoft\Office\16.0\Excel\Options";
            var currentExcelRegistries = Registry.CurrentUser.OpenSubKey(REGISTRY_PATH, true);

            currentExcelRegistries.SetValue("OPEN", "Sample.xll");

But when I open the regedit it is not there in the location. I searched the whole registry through find(in regedit) and not able to find anywhere.

I am able to see the key and value when I read back anytime:

Console.WriteLine(currentExcelRegistries.GetValue("OPEN"))

When I try to read in code it is fetching value. When I read all values in the location it gives different set of key value pair, which is totally different from which we see in regedit.

This is impacting my excel by not adding the xll.

  • Don't know why your find failed but this issue is almost always due to the 32-bit/64-bit registry redirection. – Damien_The_Unbeliever Apr 04 '22 at 07:39
  • It's probably in the 32-bit registry, meaning your application is running as 32-bit. Look in `HKCU\SOFTWARE\Wow6432Node\Microsoft\Office\...` in regedit. Either set your application to run as 64-bit (applications using newer versions of .NET do this by default, so you should probably upgrade) or you can explicitly open the 64-bit registry using [this method](https://learn.microsoft.com/en-us/dotnet/api/microsoft.win32.registrykey.openbasekey?view=net-6.0) and passing `RegistryView.Registry64` – canton7 Apr 04 '22 at 08:18
  • I've linked your question to another one: the actual question is slightly different but it's the same underlying issue, and the same answer applies – canton7 Apr 04 '22 at 08:20

0 Answers0