EventLog 服务帐户 (NT SERVICE\EventLog) 找不到或无法访问发布者 MyTestSource 资源

Publisher MyTestSource resources could not be found or are not accessible to the EventLog service account (NT SERVICE\EventLog)

我正在尝试使用来自 nuget 的 Microsoft.Diagnostics.Tracing.EventRegister 注册 EventSource。我重建我的项目并生成清单。

之后我 运行 管理员命令并执行此命令:

wevtutil.exe im "ETW loggiing.MyTestSource.etwManifest.man"

然后cmd return这个警告

**** Warning: Publisher MyTestSource resources could not be found or are not 
accessible
to the EventLog service account (NT SERVICE\EventLog).

之后我更改了文件权限

它有效,但为什么会出现此警告,我该如何用代码修复它?

我通过设置从代码访问 dll 文件来解决这个问题:

FileInfo fInfo = new FileInfo(path);
        if (fInfo.Exists)
        {
            FileSecurity security = fInfo.GetAccessControl();
            security.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), FileSystemRights.ReadAndExecute, AccessControlType.Allow));
            fInfo.SetAccessControl(security);
        }