Solved

How to write a service with Visual Studio 2005 STD?

Posted on 2008-06-23
7
161 Views
Last Modified: 2013-11-26
HI,

I've seen this article showing how to write a service (http://www.developerfusion.co.uk/show/3441/2/) with some snapshots, but the problem that i have is that i don't have all the options!

When i start a new project, i DON'T have the option WINDOWS SERVICE.  In this article, they don't mention anything about the fact that i wouldn't be able to write a service or not (http://msdn.microsoft.com/en-ca/vstudio/aa700921.aspx)...  

Anyone have this problem other than me?  Is this a limitation of the STANDARD version?

Thanks for the informations
0
Comment
Question by:cdebel
  • 4
  • 3
7 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 21854193
The only problem that you would have is that the project template is installed with the Standard version, but you should still be able to develop a Windows service, if you had the code.

You didn't mention language, but this is all you get with a C# Windows service:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
 
namespace WindowsService1
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }
 
        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.
        }
 
        protected override void OnStop()
        {
            // TODO: Add code here to perform any tear-down necessary to stop your service.
        }
    }
}

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21854197
You will need to add a reference to the System.ServiceProcess.dll to your project.
0
 
LVL 10

Author Comment

by:cdebel
ID: 21857397
I've just noticed that i can create an Empty Project.  Then i can add a "Windows Service" (just like if i add a form)...  and i get some stuff in it.  When i switch to code, i've exactly what you specified (i choosed VB.NET instead of C#).  

I also had the choice to add an installer to let it install the service, and choose how it should start (manual, auto, disabled).

So as far as i see, the pro version doesn't have much more informations available.

I'll investigate a little bit about this subject.  Thanks for your help

Imports System.ServiceProcess
 
Public Class Facilis_Media_SyncIt
 
    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
    End Sub
 
    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
    End Sub
 
End Class

Open in new window

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 10

Author Comment

by:cdebel
ID: 21859300
Hi TheLearnedOne, i think that i've closed this case a bit too fast!

It doesn't work at all!  I don't know why, but for some reasons after installing the service, i go to the Services in the admin tools, then try to start my service.  0.25 second after i pressed the Start button, it tell me that it can't start in a "timely fashion".  

Usually we get this message when it hang on the "OnStart" for too long... but actually, 0.25 second is quite fast to get this message!

I've noticed that in the Project properties the application type was set to "Windows application".  So i've uninstalled the service, change that to Windows Service, then rebuild and reinstall.  But i got the same problem.

But when i get back again in the project properties after changing the app type to Service (and saved the project), it bring back the "Windows Application" again!

I don't think that i'm the only one to have this problem.  In this article explaining how to write services, look at comment #25 (http://www.devcity.net/Articles/190/4/article.aspx).

I'll call Microsoft to understand what's going on with their stuff...
0
 
LVL 10

Author Comment

by:cdebel
ID: 21860552
I'm completely mixed up!  I just spoke with Microsoft, and they told me that i would need to upgrade.  They say that 2008 PRO should be able to let me develop Windows Services... but actually, i look at a microsoft page and they say that 2008 STANDARD should do the job (http://www.microsoft.com/products/info/product.aspx?view=22&pcid=6a94862a-9763-42db-a530-7b5c7353fbe7&crumb=catpage&catid=515c9859-958b-4433-b4f9-91f37258ca2f)

"Build software for Windows:
Develop with the Windows APIs or .NET Framework using the same tools to build Windows services, applications, utilities, games, or business applications."

I'll just give up... i'm not paying anything else.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21861493
Do you still need help?
0
 
LVL 10

Author Comment

by:cdebel
ID: 21861521
no, thanks.   I've deleted the code i've done so you can't even try what i've written  But i'm sure that Microsoft did that on purpose and my code was correct.  The only way to write a service in the Standard Edition is to write it in C++.

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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