我正在尝试使用 nuget 中的 Microsoft.Diagnostics.Tracing.EventRegister 注册 EventSource。我重建我的项目并生成 list 。
之后,我通过管理员运行 cmd 并执行此命令:
wevtutil.exe im "ETW loggiing.MyTestSource.etwManifest.man"
然后cmd返回这个警告
**** 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);
}
关于c# - EventLog 服务帐户 (NT SERVICE\EventLog) 找不到或无法访问发布者 MyTestSource 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54324680/