Error in AddinExpress.MSO.2005 OpenKey (Solved in my case).

Add-in Express™ Support Service
That's what is more important than anything else

Error in AddinExpress.MSO.2005 OpenKey (Solved in my case).
Error Received is OpenKey failed, Requested registry access is not allowed. 
Jim J




Posts: 17
Joined: 2019-03-26
Hi All,

A couple of my Excel add-in users received the following error.

---
(Inner Exception)
Assembly Codebase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Assembly Full Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version: 4.0.0.0

Exception Source: mscorlib
Exception Type: System.Security.SecurityException
Exception Message: Requested registry access is not allowed.
Exception Target Site: ThrowSecurityException

---- Stack Trace ----
System.ThrowHelper.ThrowSecurityException(resource As ExceptionResource)
mscorlib.dll: N 0016 (0x10) IL
Microsoft.Win32.RegistryKey.OpenSubKey(name As String, writable As Boolean)
mscorlib.dll: N 0000 (0x0) IL
AddinExpress.Projects.Common.ADXRegistry.OpenKey(name As String, writable As Boolean)
mscorlib.dll: N 0192 (0xC0) IL



(Outer Exception)
Assembly Codebase: file:///C:/Users/UserName/AppData/Roaming/AppCompanyName/AppName/AddinExpress.MSO.2005.DLL
Assembly Full Name: AddinExpress.MSO.2005, Version=9.5.4661.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 9.5.4661.0

Exception Source: AddinExpress.MSO.2005
Exception Type: System.Exception
Exception Message: OpenKey failed.
Exception Target Site: OpenKey

---- Stack Trace ----
AddinExpress.Projects.Common.ADXRegistry.OpenKey(name As String, writable As Boolean)
AddinExpress.MSO.2005.DLL: N 0292 (0x124) IL
AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IDTExtensibility2.OnStartupComplete(custom As Array&)
AddinExpress.MSO.2005.DLL: N 1434 (0x59A) IL

This error appeared to occur randomly and was very difficult to diagnose. I did notice that whenever the error did occur there was another Excel.exe process in the user's task manager so I originally thought it was either due to a third party application exporting to Excel or maybe the user's antivirus scanner but neither proved to be the cause.

After watching one of my users working for about 10 minutes he was finally able to reproduce the error and I noticed the cause of the error was him not double-clicking fast enough when he was using Excel's Open dialog to open an Excel file, because he had the Windows Explorer preview pane enabled it would load another instance of Excel embedded in Windows Explorer and then after about a minute the above error would generate. The error would also occur in Windows Explorer when previewing Excel files even if no instances of Excel were already running.

As a temporary solution I told him to turn off the Windows Explorer preview pane until I could figure out what was going wrong.

When I tried to replicate the issue on a virtual machine test environment with the same version of Windows (10 20H2 64 bit), Excel (365 current build 32 bit) and my Add-in there was no error and the preview pane worked as expected.

Upon further research I learned the broken preview pane maybe due to the un-installation of 64 bit Office and the re-installation of 32 bit Office. So on my test machine, I un-installed the 32 bit Office, installed the 64 bit Office then un-installed the 64 bit Office and re-installed the 32 bit Office and sure enough the same error appeared whenever previewing Excel files through Windows Explorer.

My guess as to why the error occurs is when you un-install Office it does not remove all the necessary registry entries required to enable the preview pane functionality. Therefore, when 64 bit Office was un-installed the preview pane registry entries are left behind and when you invoke the Windows Explorer preview pane with 32 bit Office installed it actually checks the 64 bit location first because the OS is 64 bit. When it finds the 64 bit preview pane entries it then gets led down an invalid path that causes the embedded Excel instance to be started under the wrong context thus causing the error above.

The other side effect of these old 64 bit Office registry entries is it will break the preview pane of all Office files including Word and PowerPoint even if your add-in doesn't target those applications. While there will be no error for the other Office applications they will still fail to preview in the Windows Explorer preview pane.

To fix the issue all that needs to be done is to import the following registry adjustments and reboot your computer.


Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\CLSID\{00020827-0000-0000-C000-000000000046}]
[-HKEY_CLASSES_ROOT\CLSID\{65235197-874B-4A07-BDC5-E65EA825B718}]
[-HKEY_CLASSES_ROOT\CLSID\{84F66100-FF7C-4fb4-B0C0-02CD7FB668FE}]


Note, the above must be imported by and Administrator as they affect the HKEY_CLASSES_ROOT folder. Also, this patch should only be provided to user's experiencing the exact above error and are running the 32 bit version of Microsoft Office. The first registry entry removal fixes Excel's preview pane, the second PowerPoint and the third Word.

Once the above registry entries are imported and the computer is rebooted the Windows Explorer preview pane should work again and no error should be generated with your add-in

Maybe Add-In-Express can replicate the error now and possibly provide a more meaningful error message, though if not, at least it is now documented.

I also found the following 6 forum topics by other users who may have experienced the same error described above with some of their users.


https://www.add-in-express.com/forum/read.php?FID=5&TID=15289

https://www.add-in-express.com/forum/read.php?FID=5&TID=15374

https://www.add-in-express.com/forum/read.php?FID=5&TID=15623

https://www.add-in-express.com/forum/read.php?FID=5&TID=15741

https://www.add-in-express.com/forum/read.php?FID=5&TID=15814

https://www.add-in-express.com/forum/read.php?FID=5&TID=16073


Hope this helps,
Regards,
Jim
Posted 24 Jun, 2021 12:01:03 Top
Andrei Smolin


Add-in Express team


Posts: 19138
Joined: 2006-05-11
Hello Jim,

Thank you a lot for describing the issue and solution. We will consider providing more info for developers.

To prevent the exception you can also handle the ADXAddinModule.OnError event: it allows marking the exception as handled.


Andrei Smolin
Add-in Express Team Leader
Posted 28 Jun, 2021 04:52:26 Top
Jim J




Posts: 17
Joined: 2019-03-26
Hi Andrei,

Thanks.

I actually did add on option to my setting form that allows my users to ignore that specific error and I used that exact event to report back that the error was handled.

Regards,
Jim
Posted 28 Jun, 2021 20:09:49 Top