Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 23rd, 2008, 10:20 AM
Registered User
 
Join Date: Jun 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Service Issues

I am new to C# programming. I can program Java, but I don't know the studio or its error messages very well.

Here is a code sample from a service tutorial I was trying to build.

  public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            // Add code here to start your service. This method should set things
            // in motion so your service can do its work.

            MyTimer.Enabled = True;

        }

        protected override void OnStop()
        {
            // TODO: Add code here to perform any tear-down necessary to stop your service.
        }

        private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
           EventLog Mylog = new EventLog();
           /* create an event log */
           /* Check if the the Event Log Exists */

           /*If MyLog.SourceExists("NewService"){}*/
           if (System.Diagnostics.EventLog.Exists("NewService"))
           {}else{
           MyLog.CreateEventSource("NewService", "NewService_Log");
            /* Create Log */
           }


          MyLog.Source = "NewService" ;
          /* Write to the Log */
          MyLog.WriteEntry("NewService_Log", "Service is Running" , EventLogEntryType.Information);

        }

I get the following error messages:

Error 1 The name 'MyTimer' does not exist in the current context
Error 2 The name 'True' does not exist in the current context
Error 3 The name 'MyLog' does not exist in the current
Error 4 The name 'MyLog' does not exist in the current
Error 5 The name 'MyLog' does not exist in the current

Thanks for the help.
Reply With Quote
  #2 (permalink)  
Old July 19th, 2008, 09:19 PM
Authorized User
 
Join Date: May 2007
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Peter_APIIT
Default

No idea what you talking here.

Linux is the best OS in the world.
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Impersonate with windows service for Service A/C vinod_yadav1919 C# 0 October 18th, 2008 02:29 PM
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
Service Oriented Web Service aldwinenriquez .NET Web Services 2 September 15th, 2005 03:25 AM
ReportServer Service Issues DVeit BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 8th, 2004 09:54 PM
Reporting Service Install Issues jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 5 June 23rd, 2004 10:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.