• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

Installing Windows Service For Debugging...

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
Ben Santiardo
Asked:
Ben Santiardo
  • 7
  • 4
  • 2
  • +1
1 Solution
 
Nash2334Commented:
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
 
Ben SantiardoAuthor Commented:
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
 
CodeCruiserCommented:
Are you running the InstalUtil from correct framework folder and giving full path to service exe?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Ben SantiardoAuthor Commented:
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
 
CodeCruiserCommented:
If the service is compiled correctly without errors then it should appear in the list. It is written in .NET 4 right?
0
 
Ben SantiardoAuthor Commented:
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
 
nffvrxqgrcfqvvcCommented:
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
 
Ben SantiardoAuthor Commented:
@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
 
nffvrxqgrcfqvvcCommented:
Umm yeah but if you haven't not targeted the correct InstallUtil or elevated the command prompt then it wouldn't install correctly
0
 
Ben SantiardoAuthor Commented:
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
 
nffvrxqgrcfqvvcCommented:
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
 
Ben SantiardoAuthor Commented:
@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
 
nffvrxqgrcfqvvcCommented:
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
 
Ben SantiardoAuthor Commented:
@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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 7
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now