c# - 将事件写入事件日志期间出现 WCF 异常

标签 c# winforms wcf events exception

在托管名为我的机器的 WCF 服务的主机 (Windows 2008 R2) 上写入事件日志时出现异常 来自在域内但在不同计算机上运行的 WCFClient (Windows 7)。

模拟 WCF 客户端以访问服务器上的资源。

到目前为止,以下链接没有帮助

http://support.microsoft.com/kb/2028427#appliesto

http://forums.asp.net/t/1131903.aspx

http://msdn.microsoft.com/en-us/library/Aa379567(关于 SDDL 的详细信息) http://blogs.dirteam.com/blogs/jorge/archive/2008/03/26/parsing-sddl-strings.aspx(SDDL)

关于SO的类似问题没有任何答案 https://stackoverflow.com/questions/6456444/allow-wcf-services-writing-to-custom-event-log-under-windows-2008-r2-server

异常情况如下

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]:无法打开源“MyService”的日志。您可能没有写入权限。 (Fault Detail 等于 An ExceptionDetail,很可能是由 IncludeExceptionDetailInFaults=true 创建的,其值为: System.InvalidOperationException:无法打开源“MyService”的日志。您可能没有写入权限。 ----> System.ComponentModel.Win32Exception: 访问被拒绝

--- 内部 ExceptionDetail 堆栈跟踪结束 --- 在 System.Diagnostics.EventLogInternal.OpenForWrite(字符串 currentMachineName) 在 System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 事件 ID、UInt16 类别、EventLogEntryType 类型、字符串 [] 字符串、字节 [] 原始数据、字符串 currentMachineName) 在 System.Diagnostics.EventLogInternal.WriteEntry(字符串消息,EventLogEntryType 类型,Int32 eventID,Int16 类别,Byte [] rawData) 在 System.Diagnostics.EventLog.WriteEntry(字符串消息,EventLogEntryType 类型) ...................... .....................

最佳答案

这是自定义事件日志吗?如果是这样,请参阅

http://msdn.microsoft.com/en-us/library/49dwckkz(v=vs.80).aspx

——尤其是

In general, create the new event source during the installation of your application. This allows time for the operating system to refresh its list of registered event sources and their configuration. If the operating system has not refreshed its list of event sources and you attempt to write an event with the new source, the write operation will fail. If creating the source during installation is not an option, then try to create the source well ahead of the first write operation, perhaps during your application initialization. If you choose this approach, be sure your initialization code is running with administrator rights on the computer. These rights are required for creating new event sources.

关于c# - 将事件写入事件日志期间出现 WCF 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8012179/

相关文章:

c# - 使用 DevExpress 时删除表单上的 "Close"图标

c# - 如何使选项卡的名称在 C# 中可编辑?

asp.net - WCF 服务在/js 请求上返回错误 500

c# - 如何从 Chrome 驱动程序(Selenium Web 驱动程序 C#)中分离 Chrome 浏览器

c# - 选择所有列,但在 linq 中仅按一个分组

c# - 使用 ShowDialog 显示对话框时如何控制对话框的位置?

c# - WCF 服务主机何时销毁自定义 IDispatchMessageInspector?

c# - 从 HTTPClient 响应中解压 GZip 流

javascript - 如何将日期时间值附加到表单数据并在 Controller 中接收它

c# - 从文件中读取哈希表#