When using Excel Import product to upload and import an Excel to a SharePoint list, you may meet this issue "An unexpected error has occurred" as this.
After digging into the SharePoint logs, there will be error message like this: "Requested registry access is not allowed."
Or upload and import a .csv format file using Excel Import, then you will find a same error message in the logs.
Solution:
Why does this issue happen?
In the product Excel Import, we use "Package" class to load and parse excel file before import to list.
"Package" (full name: "System.IO.Packaging.Package") is a standard dot net class which defined in WindowsBase.dll and is part of the windows system. It will try write event trace during package class initialization, before write event trace, system will check which provider to use by reading the "ClassicETW" value in registry key "HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics\".
In some cases, the windows identity which the SharePoint process running with does not have permission to read that registry, as a result, an SecurityException was thrown saying "Requested registry access is not allowed."
In short, the system module needs to read registry key "HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics\" to decide where to write event trace, but SharePoint process doesn’t have permission to access it.
How to fix it?
Firstly, log in one application or web front end server, open the Register Editor.
And then find the HKEY_CURRENT_USER\Software\Microsoft\Avalon. Graphics, right-click it and choose Permission option and add Everyone and grant Read permission as following, and then restart this server.
Repeat above steps, modify the registry in all application and web front end servers, and restart the servers.
If above steps do not work, the cause of it may be the HKEY_CURRENT_USER for SharePoint process is different from for current login user while you modify the registry. So, you need to find the right "current user" for SharePoint process, or just grant permission for all users.
Registry key "HKEY_CURRENT_USER\Software\Microsoft\Avalon.Graphics\" is under the HKEY_CURRENT_USER hive, all settings here are user-level settings, and for current logged in user only. In some cases, it is not the settings that SharePoint process was reading.
Since HKEY_CURRENT_USER hive is just a subkey of HKEY_USERS, here you can grant Everyone read permission on another user’s registry key.
You can see many user IDs under HKEY_USERS hive, go through each user to find registry key "HKEY_USERS\<some user id>\Software\Microsoft\Avalon.Graphics\", if that key exists, grant "Everyone" read permission on it.
e.g.: HKEY_USERS\S-1-5-21-1343462910-744444023-3288617952-4375\Software\Microsoft\Avalon.Graphics\
Repeat above steps, modify the registry in all application and web front end servers, and restart the servers.
Once the registry key which SharePoint is reading has the right permission, the issue will be fixed, the product should work.
Applies for: SharePoint 2019, SharePoint 2016