C# 找不到发布服务器MyTestSource资源,或者无法访问EventLog服务帐户(NT service\EventLog)

C# 找不到发布服务器MyTestSource资源,或者无法访问EventLog服务帐户(NT service\EventLog),c#,etw,wevtutil,C#,Etw,Wevtutil,我正在尝试从nuget使用Microsoft.Diagnostics.Tracing.EventRegister注册EventSource。我重建项目并生成清单 之后,我通过admin运行cmd并执行以下命令: wevtutil.exe im "ETW loggiing.MyTestSource.etwManifest.man" 然后返回此警告 **** Warning: Publisher MyTestSource resources could not be foun

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

之后,我通过admin运行cmd并执行以下命令:

wevtutil.exe im "ETW loggiing.MyTestSource.etwManifest.man"
然后返回此警告

**** 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);
        }