R
Ron Hinds
I'm developing a Windows Service in VB.Net. In the Visual Studio
Programmer's Guide for the .NET Framework - How to: Log Information About
Services, the following statement is made:
By default, all Windows Service projects have the ability to interact with
the Application event log and write information and exceptions to it. You
use the AutoLog property to indicate whether you want this functionality in
your application. By default, logging is turned on for any service you
create with the Windows Service project template. You can use a static form
of the EventLog class to write service information to a log without having
to create an instance of an EventLog component or manually register a
source.
So, in my code, I use the following:
EventLog.WriteEntry("Socket connected!")
But the IDE indicates there is a problem, and this is the error message:
Error 1 Reference to a non-shared member requires an object reference.
EventLog.Write Entry is Shared, but it requires an instance of an
EventInstance, and the methods require using a resource file. This app is
for use only in our company and I really don't want to go to the trouble of
creating a resource file, etc. (trying to keep it simple ;-).
Can anyone point me to a sample of a Windows Service that uses the default
AutoLog showing how to do the logging? Thanks!
Programmer's Guide for the .NET Framework - How to: Log Information About
Services, the following statement is made:
By default, all Windows Service projects have the ability to interact with
the Application event log and write information and exceptions to it. You
use the AutoLog property to indicate whether you want this functionality in
your application. By default, logging is turned on for any service you
create with the Windows Service project template. You can use a static form
of the EventLog class to write service information to a log without having
to create an instance of an EventLog component or manually register a
source.
So, in my code, I use the following:
EventLog.WriteEntry("Socket connected!")
But the IDE indicates there is a problem, and this is the error message:
Error 1 Reference to a non-shared member requires an object reference.
EventLog.Write Entry is Shared, but it requires an instance of an
EventInstance, and the methods require using a resource file. This app is
for use only in our company and I really don't want to go to the trouble of
creating a resource file, etc. (trying to keep it simple ;-).
Can anyone point me to a sample of a Windows Service that uses the default
AutoLog showing how to do the logging? Thanks!