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

标签 c# etw wevtutil

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

Debug

之后,我通过管理员运行 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).

之后我更改了文件权限

permission

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

最佳答案

我通过设置从代码访问 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/

相关文章:

etw - 如何列出所有事件的 ETW session 及其输出位置(也许在 Powershell 中)?

c# - 带有服务总线的Azure功能: How to keep a message in the queue if something goes wrong with its processing?

c++ - 为什么 ETW EventWriteString 有二进制负载

c# - C# TcpListener 和 Java ServerSocket 的区别

profiling - 从 GCSampledObjectAllocationHigh 转换 TypeId

xpath - 如何在 wevtutil 中使用 xpath 检索特定时间以来的事件

c++ - 为什么在成功调用 EventWrite 函数后我的 Windows 日志为空

c# - 如何将 IEnumerable 模型传递给 MVC 中的局部 View

c# - 错误 : Object must implement IConvertible