NewMom2Brandon
asked on
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.ToSt ring(),
"dateTimeRunLast = " + dateTimeRunLast.ToString() ,
System.Diagnostics.EventLo gEntryType .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
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.ToSt
"dateTimeRunLast = " + dateTimeRunLast.ToString()
System.Diagnostics.EventLo
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
ASKER
I added it and it still comes up with the same error
ASKER
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"
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.
If he posts the solution, then we can decide if we have an objection or not.
ASKER
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.Insta ll;
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.EventLo g.WriteEnt ry worked.
System.Diagnostics.EventLo g.WriteEnt ry("Promis e Message Agent",
"Rebuilding successfully completed for disk " + Convert.ToString(cDoubleQu otes) +
"ST380013AS(Ch2)" + Convert.ToString(cDoubleQu otes) + " in Array " +
Convert.ToString(cDoubleQu otes) + "PROMISE Array 1" +
Convert.ToString(cDoubleQu otes) + ".", EventLogEntryType.Error, 533, 0);
second here is what I did:
Install.cs file
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Insta
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.EventLo
System.Diagnostics.EventLo
"Rebuilding successfully completed for disk " + Convert.ToString(cDoubleQu
"ST380013AS(Ch2)" + Convert.ToString(cDoubleQu
Convert.ToString(cDoubleQu
Convert.ToString(cDoubleQu
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.
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.
I agree
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
using System.Diagnostics;