Solved

How to write a service with Visual Studio 2005 STD?

Posted on 2008-06-23
7
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

 
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

718 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