?
Solved

Installing Windows Service For Debugging...

Posted on 2011-04-29
14
Medium Priority
?
474 Views
Last Modified: 2012-05-11
I am attempting to "convert" a Windows Forms Application into a Windows Service, with an accompanying Windows Form UI to inteface with said Service.

So I've created a new Windows Service, copied a chunck of my code over, made necessary tweeks for it now being a Service rather then a Forms App.  I built (AKA compiled) my code, and then (since you cannot run Services in IDE debug-mode directly) manually installed the Service executable using the [InstallUtil <ServiceFile.exe>] command.  It goes through the motions, echoing a bunch of information about the install, at the end stating "The transacted install has completed."  At this point I expected to see my Service listed with all the other services on the machiene...  No such luck...  Is there something I am missing here?  
0
Comment
Question by:Ben Santiardo
  • 7
  • 4
  • 2
  • +1
14 Comments
 
LVL 10

Expert Comment

by:Nash2334
ID: 35493334
It's probably easier to create an installer project for your Windows Service in Visual Studio and then install it from that project through the IDE.  You can then attach to the service process and debug it as well.
0
 

Author Comment

by:Ben Santiardo
ID: 35493548
Well, I guess I could do that, but that's a lot of effort when I am still in development, there are other files that have to be in the same directory as the executable as well.  Would be annoying to have to design a whole installer routine just to be able to debug one exe...  Then everytime I want to retest after a change in code I woul dhave to uninstall and reinstall using the Installer Project... just seems like a lot of extra work...
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35493648
Are you running the InstalUtil from correct framework folder and giving full path to service exe?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Ben Santiardo
ID: 35493695
Umm...oops.  I was running InstalUtil from the folder of the Sevice.exe...I don't know which InstallUtil it was running...  Let me try from the Framework4 folder...

Ok, I just tried it from the C:\Windows\Microsoft.Net\Framework\v4.0.30319 folder....same thing.  Looks like it works, but I can't find the service in my "Services" list.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35493822
If the service is compiled correctly without errors then it should appear in the list. It is written in .NET 4 right?
0
 

Author Comment

by:Ben Santiardo
ID: 35493858
Yes it's written in .Net4   I have no trouble compiling, no errors at all.  But after I "install" it, I just can't seem to find the little bastard in the list of Services.  I am getting so frustrated because nothing is giving off an error...so how in the world am I supposed to know if something is wrong?  ARG!  What a way to end a week and start my weekend.
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 35494191
I just drop batch files into the bin directory ( one batch file that installs and another that removes the service) I use batch file because you can elevate them with administrator privileges which is required to fully install your services.

In the examples change to target the framework location your using with your service and the executable name then drop the batch files into the bin folder with executable. Right click the batch files and Run as Administrator. This makes things easier but you could even disable UAC temporarly since it does get annoying that is if your using Vista or later
// My installer batch

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe svcProject.exe
PAUSE

// My un-installer batch

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /U svcProject.exe

Open in new window

0
 

Author Comment

by:Ben Santiardo
ID: 35494268
@egl1044:

Umm, thanks for the info, but that is exactly what I am executing, just not in BATCH format at the moment.  Once I get it working, I was planning on creating some sort of automation for Installing & Uninstalling.  Problem is...getting it to work...
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 35494380
Umm yeah but if you haven't not targeted the correct InstallUtil or elevated the command prompt then it wouldn't install correctly
0
 

Author Comment

by:Ben Santiardo
ID: 35504700
Since no one has any clues yet, I figured i'd post the InstallUtil's output, maybe there is something there that someone see's which might be a problem.  This is my first Service so I am not sure if this output is good.  All I know is that it says Success at the end...so to me, it should be working...


C:\Windows\Microsoft.NET\Framework\v4.0.30319>InstallUtil "C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe"

Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe assembly's progress.
The file is located at C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.InstallLog.
Installing assembly 'C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe'.
Affected parameters are:
   logtoconsole =
   logfile = C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.InstallLog
   assemblypath = C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe
No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe assembly.

The install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file for the C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe assembly's progress.
The file is located at C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.InstallLog.
Committing assembly 'C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe'.
Affected parameters are:
   logtoconsole =
   logfile = C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.InstallLog
   assemblypath = C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe
No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\VB.Net Programs\Test Scoring\Server\bin\Debug\Server_Service.exe assembly.
Remove InstallState file because there are no installers.

The Commit phase completed successfully.

The transacted install has completed.
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 35504838
In your service solution explorer double click your service componet file then in the working area right click and choose "Add installer" from the context menu.
0
 

Author Comment

by:Ben Santiardo
ID: 35504988
@egl1044:

Forgive me I am a little lost in following your directions.  What "exactly" should I double-click in the Solution Explorer? I've opened the "Main.vb" file which is where the Service starts execution.  But when I right-click for the context menu, I see no such option "Add Installer"...
0
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 2000 total points
ID: 35504989
I had to dig around but this is the guide I used when I first made a service it's well written so give it a go if you still have problems. The output you show is indicating you forgot to add the installer to your project. It's misleading so don't confuse this with anything MSI related.

You could jump to the section: "To create the installers for your service" but mine as well read the whole walkthrough

Walkthrough: Creating a Windows Service Application in the Component Designer
http://msdn.microsoft.com/en-us/library/zt39148a.aspx
0
 

Author Comment

by:Ben Santiardo
ID: 35505153
@egl1044:

Thank you!  Now I understand what you meant with regards to adding an installer.  That was my problem.  I was not aware of that particular step in the creating of a service.  Now the Service shows up in my list.  Of course, it crashed on my first attempt at running it, but that's fine, at least it's there now.  Thanks again!!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

831 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