当我尝试用类似于EventLog.WriteEntry("MyEsb", "Msg");表达式的形状执行编排时,我得到异常The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.为什么?如果这有任何意义,我正在运行Win 7 64bit.
从任何应用程序编写事件日志时,需要已创建事件源,或者应用程序本身将在写入之前尝试创建事件源.不幸的是,创建事件源是一项需要本地管理员权限的操作.
所以你可以做两件事:
预先创建事件源是一个更好的选择.您可以通过powershell命令执行此操作
New-EventLog -LogName "Application" -Source "MyEsb"
Run Code Online (Sandbox Code Playgroud)