Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6815817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:51:08+00:00 2026-05-26T20:51:08+00:00

I am using Microsoft Visual C# 2010 Express. I did not have access to

  • 0

I am using Microsoft Visual C# 2010 Express. I did not have access to a Windows Services template so I downloaded one online. I am trying to implement a timer into my project and I am getting the following errors.

Error 1 Invalid token ‘=’ in class, struct, or interface member
declaration C:\Documents and Settings\bruser\My Documents\Visual
Studio 2010\Projects\WindowsService\Service1.cs 19 23 windowsservice

Error 2 Method must have a return type C:\Documents and
Settings\bruser\My Documents\Visual Studio
2010\Projects\WindowsService\Service1.cs 19 29 windowsservice

Error 3 The type or namespace name ‘timer’ could not be found (are you
missing a using directive or an assembly reference?) C:\Documents and
Settings\bruser\My Documents\Visual Studio
2010\Projects\WindowsService\Service1.cs 19 17 windowsservice

Error 4 The name ‘timer’ does not exist in the current
context C:\Documents and Settings\bruser\My Documents\Visual Studio
2010\Projects\WindowsService\Service1.cs 23 4 windowsservice

Error 5 The name ‘OnElapsedTime’ does not exist in the current
context C:\Documents and Settings\bruser\My Documents\Visual Studio
2010\Projects\WindowsService\Service1.cs 23 45 windowsservice

Error 6 The name ‘timer’ does not exist in the current
context C:\Documents and Settings\bruser\My Documents\Visual Studio
2010\Projects\WindowsService\Service1.cs 24 13 windowsservice

Error 7 The name ‘timer’ does not exist in the current
context C:\Documents and Settings\bruser\My Documents\Visual Studio
2010\Projects\WindowsService\Service1.cs 25 13 windowsservice

Service1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Timers; 

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

    private timer = new Timer();

    protected override void OnStart(string[] args)
    {
        timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
        timer.Interval = 30000; // every 30 seconds
        timer.Enabled = true;

    }

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

The namespace in both Program.cs and Service1.cs were named $SaveNamespace$. So, I changed both of them to SendFax. Should these two files have separate namespace names?

I changed onElapsedTime to Tick. Do the namespaces need to be named different on Program.cs and Service1.cs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:51:09+00:00Added an answer on May 26, 2026 at 8:51 pm

    You are missing the variable type here.

    private timer = new Timer();
    

    Try:

    private Timer timer = new Timer();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Friends I have been using Microsoft Visual C++ 2010 Express edition and also downloaded
I am using Microsoft Visual Basic 2010 Express. I have a WPF-based project. I
What have I done? I'm using Microsoft Visual Studio 2010 1) I downloaded libevent-2.0.16-stable
I have written a program using Microsoft Visual C# 2010 Express. I need to
Background-info: I'm using Microsoft Visual Web Developer 2010 Express. Info about my (lack of)
im writing an application using Visual Studio 2010 Express Edition. I have a problem
I am developing a Microsoft Surface 2.0 application using Visual C# 2010 Express Edition.
I developed a website using Microsoft Visual Web Developer 2010. I'm not a serious
I am using microsoft visual web developer 2010 express edition. i want to create
I'm a beginner starting to use Microsoft Visual C++ Express 2010 for Windows Programming.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.