当我编译以下代码时,它将错误显示为 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.");
}
} }
如何修复此错误