ASAP ERROR HELP "The type or namespace name 'myLog' could not be found "

I read that you have to declare a source for event log prior to the installer running so I placed the following code in my file called clientinstaller which is in the main project

  public QMonitorInstaller()
        {

          // Create an EventLog instance and assign its source.

          EventLog myLog = new EventLog();
          myLog.Source = "System";

            ServiceProcessInstaller process = new ServiceProcessInstaller();

            process.Account = ServiceAccount.LocalSystem;

            ServiceInstaller serviceAdmin = new ServiceInstaller();

            serviceAdmin.StartType      = ServiceStartMode.Automatic;
            serviceAdmin.ServiceName    = "QMonitor";
            serviceAdmin.DisplayName    = "QMonitor";
           

            Installers.Add( process );
            Installers.Add( serviceAdmin );
        }    
    }    

I also have another file in a connecting Project which contains this line of code

using System;
using System.Xml;
using System.IO;
using System.Collections;
using System.Net;
using Microsoft.Win32;


                myLog.WriteEntry(this.ToString(),
                "dateTimeRunLast = " + dateTimeRunLast.ToString(),
                System.Diagnostics.EventLogEntryType.Error);

I am getting a error error CS0246: The type or namespace name 'myLog' could not be found (are you missing a using directive or an assembly reference?)  How can I fix this error....I try to reference the first project but it says I need a dll...but this is the main project .exe
LVL 2
NewMom2BrandonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

stumpy1Commented:
You need to have the following using directive in your code to use the EventLog

using System.Diagnostics;
0
NewMom2BrandonAuthor Commented:
I added it and it still comes up with the same error
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

NewMom2BrandonAuthor Commented:
That link doesn't help much. It is asking for a dll. How do I make a dll to reference the first project which is listed as .exe. How would I reference the Project installer which is where the source for the eventlog is set to be "System"
0
stumpy1Commented:
It would be curtious if he would give us feedback in the thread as to what solved the problem as opposed to just saying 'I found the answer myself'.
If he posts the solution, then we can decide if we have an objection or not.
0
NewMom2BrandonAuthor Commented:
First off I am not a he!

second here is what I did:

Install.cs file

using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
using System.Diagnostics; ***THIS WAS ALREADY THERE SO THAT DID NOT DO ANYTHING***
 public QMonitorInstaller()
        {

          // Create an EventLog instance and assign its source.

           EventLog myLog = new EventLog("System");
           myLog.Source = "message Agent";

            ServiceProcessInstaller process = new ServiceProcessInstaller();

            process.Account = ServiceAccount.LocalSystem;

            ServiceInstaller serviceAdmin = new ServiceInstaller();

            serviceAdmin.StartType      = ServiceStartMode.Automatic;
            serviceAdmin.ServiceName    = "QMonitor";
            serviceAdmin.DisplayName    = "QMonitor";
           

            Installers.Add( process );
            Installers.Add( serviceAdmin );
        }    
    }    

in my other file

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics; ***EVEN ADDING THIS DID NOT REMOVE THE ERROR INITIALLY until I fixed to code in the installer
using System.ServiceProcess;
using System.Threading;

the normal System.Diagnostics.EventLog.WriteEntry worked.

            System.Diagnostics.EventLog.WriteEntry("Promise Message Agent",
                "Rebuilding successfully completed for disk " + Convert.ToString(cDoubleQuotes) +
                "ST380013AS(Ch2)" + Convert.ToString(cDoubleQuotes) + " in Array " +
                Convert.ToString(cDoubleQuotes) + "PROMISE Array 1" +
                Convert.ToString(cDoubleQuotes) + ".", EventLogEntryType.Error, 533, 0);
0
stumpy1Commented:
Firstly, Please accept my Apologies for the he, if I had taken heed of the username I might have got it right. I try to use (s)he syntax but forget to a lot of the time.
Secondly, I am very glad that you got the problem fixed.
Thirdly, Since you have posted the solution you found this may be a be a useful PAQ for some other soul that runs into a similar problem. Thanks for posting the solution.

My recommendation is that this question should be Paq'd and NewMom2Brandon should have her question points refunded.
0
hesCommented:
I agree
0
ee_ai_constructCommented:
Question answered by asker or dialog valuable.
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.