• Question

  • How to write event to log messages? Basically when one of my functions is done with processing, i need to use event to log the message that my function is done with processing and what ever comes next is okay to start ...
    Monday, November 16, 2009 6:08 PM


All replies

  • Hi,

    You can use eventlog class.


    Here is a sample

    EventLog.WriteEntry("Application", "My function Is done working",EventLogEntryType.Information); 
    • Proposed as answer by Tamer Oz Sunday, November 22, 2009 11:50 AM
    • Marked as answer by Harry Zhu Monday, November 23, 2009 2:44 AM
    Monday, November 16, 2009 6:21 PM
  • I am getting this error message:
    Error 1 'EventLog' does not contain a definition for 'SourceExists'
    Monday, November 16, 2009 6:41 PM
  • It's a static method.

    You can not call it from an instance of eventlog class.

    You can call it directly from class type.

    Like EventLog.SourceExists

    not like Ecentlog e = new Eventlog(); e.SourceExists.
    Monday, November 16, 2009 6:45 PM
  • I have one very simple question. Can one project in .NET have multiple mains? Right now I have the main, which needs to call the class (separate file- where I wanted to add this log event function). When I add l.e. function to a class without a main (because another main already exist) i get multiple errors (invalid token ...).
    Monday, November 16, 2009 8:08 PM
  • I didn't understand exactly what you are trying to do.

    Could you explain it by code.
    Tuesday, November 17, 2009 9:06 AM
  • Maybe this is a new topic, but this is what I am trying to do and can't solve the problem. I am trying to login automatically to an external website through console application. (I asked this question earlier but) what I don't know how to do is this:

    Right now there is a main like this: 

    class  loginToExternalWebsite
            static void MainXXX()
                wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);

             static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

    However, this function (Log in) needs to be inside the class, separate file and it can't have the main because main already exist and this login to external class will be called from within main. I don't know how to change it so that it functions without a main. So, it will look like this

         using loginToExternalWebsite;//that's the class


    no matter what I do, I can't make it work. I don't know how to get rid off the mainXXX() so that the class can be called from within mainA(); 
    Tuesday, November 17, 2009 1:25 PM
  • Hi,

    Since the MainXXX method is static and the namespaces of classes are same Try the following.



    Wednesday, November 18, 2009 4:23 AM