System.ServiceProcess.ServiceBase继承的类中有EventLog属性,直接用即可!

解决方案 »

  1.   

    Try
                    If Not EventLog.SourceExists("TestLog") Then
                        EventLog.CreateEventSource("TestLog", "TestLog")
                    End If
                    Dim oLog As New EventLog()
                    oLog.Source = "TestLog"
                    oLog.WriteEntry("TestLog", eventLogMessage, eventLogType)
                    oLog = Nothing
                Catch Exp As Exception
                    'Do Nothing
                End Try
      

  2.   

    http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B329291http://www.4guysfromrolla.com/webtech/chapters/ASPNET2/ch02.9.shtml
      

  3.   

    在C#中有System.ServiceProcess这个名称空间吗?
    我试了下面这段程序也不行:
    if(!System.Diagnostics.EventLog.SourceExists("Service1"))
    {
          System.Diagnostics.EventLog.CreateEventSource("Service1","测试");
    }
    eventLog1.Source="Service1";
      

  4.   

    资料挺多的!看Help Or Google!
      

  5.   

    我定义了这么个函数,可是总报错说“不允许所请求的注册表访问权”
    借宝地一块问问该怎么改
    protected void LogEvent(string message,EventLogEntryType entryType)
    {
      if(!EventLog.SourceExists("mytest"))
      {
         EventLog.CreateEventSource("mytest","Application","mypc");
      }
      EventLog.WriteEntry("mytest",message,entryType);
    }
      

  6.   

    手动创建
    好好研读一下这个KB
    http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B329291