?
Solved

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

Posted on 2004-11-09
10
Medium Priority
?
342 Views
Last Modified: 2009-07-29
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
0
Comment
Question by:NewMom2Brandon
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 5

Expert Comment

by:stumpy1
ID: 12535049
You need to have the following using directive in your code to use the EventLog

using System.Diagnostics;
0
 
LVL 2

Author Comment

by:NewMom2Brandon
ID: 12535067
I added it and it still comes up with the same error
0
 
LVL 20

Expert Comment

by:hes
ID: 12535162
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:NewMom2Brandon
ID: 12535978
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
 
LVL 5

Expert Comment

by:stumpy1
ID: 12553451
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
 
LVL 2

Author Comment

by:NewMom2Brandon
ID: 12555898
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
 
LVL 5

Expert Comment

by:stumpy1
ID: 12556450
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
 
LVL 20

Expert Comment

by:hes
ID: 12556921
I agree
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12578919
Question answered by asker or dialog valuable.
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question