I'm trying to debug a server solution which stopped working when it was migrated into SP 2019 (not sure if it was migrated from 2013 or 2016). The solution is using SPSecurity.RunWithElevatedPrivileges in an event receiver.
SPSecurity.RunWithElevatedPrivileges(delegate () { using (SPSite site = new SPSite(properties.SiteId)) { using (SPWeb web = site.OpenWeb(properties.Web.ID)) { ... The code modifies the permissions of documents uploaded and saved into a document library if 'Protection' is selected as the value of a particular field.
The code is clearly running under the app pool account in the debugger, but it is only working when the user is a site collection admin. In other words it is actually running with the permissions of the user who uploaded/saved the document.
Can anyone hazard a guess as to what might be going on or suggest how to go about debugging it?