首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >System.SecurityException错误

System.SecurityException错误
EN

Stack Overflow用户
提问于 2013-02-01 18:03:09
回答 3查看 11.7K关注 0票数 3

当我编译以下代码时,它将错误显示为system.securityexception错误。

代码语言:javascript
复制
using System;    
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
namespace eventlog
{
   class MySample{

public static void Main(){

   if(!EventLog.SourceExists("MySource"))
    {            
        EventLog.CreateEventSource("MySource", "MyNewLog");
        Console.WriteLine("CreatedEventSource");
        Console.WriteLine("Exiting, execute the application a second time to use the source.");
        return;
    }        EventLog myLog = new EventLog();
    myLog.Source = "MySource";
   myLog.WriteEntry("Writing to event log.");

}

}}

如何修复此错误

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-02-01 18:09:56

我认为您必须拥有管理员特权才能创建新的EventLog。

票数 3
EN

Stack Overflow用户

发布于 2013-02-01 18:40:20

阅读本文:http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx

这就是为什么每个人都说不要用模拟的方式写入事件日志。您必须将用户或用户组放入不建议使用的本地管理员组中。服务用户可能具有此权限。

票数 2
EN

Stack Overflow用户

发布于 2016-01-21 16:04:06

更明确地说,右击应用程序(exe)并选择“以管理员身份运行”

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14643780

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档