Solved

How to write a service with Visual Studio 2005 STD?

Posted on 2008-06-23
7
160 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now