gpt4 book ai didi

c# - System.SecurityException 错误

转载 作者:行者123 更新时间:2023-11-30 15:01:09 25 4
gpt4 key购买 nike

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

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.");

}

}

如何修复这个错误

最佳答案

我认为您必须具有管理员权限才能创建新的事件日志。

关于c# - System.SecurityException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14643780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com