Installing a Windows Service -Setup.exe fails - c#

There is a weird issue I am facing. I created my first windows service looking through various blogs and tutorials.
Then created setup for that adding installer etc. It works fine while installing , un-installing via Visual Studio but it fails when i deploy it .
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of C:\Users\bhuvint\Documents\Visual Studio 2010\Projects\CPNS Library\ServicePackage\CommonPushNotificationWindowsService.application resulted in exception. Following failure messages were detected:
+ You cannot start application CommonPushNotificationWindowsService from this location because it is already installed from a different location.
+ You cannot start application CommonPushNotificationWindowsService from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application it is already installed from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application. You can start it from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application or you can uninstall it and reinstall it from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application.
I have already un-installed the service and trying to install it from the deployed service in the same pc to test. But it fails with above error.
I feel i have deployed the windows service the wrong way. Could you guys please suggest how to deploy a windows service ?? (I have looked through net. All suggest building it and installing it from visual studios. But how to publish it is the thing which i need.)
Please help asap.

Possibly you built the setup project before uninstalling the preovious service. In that case you can't use the new setup to uninstall the service, since the setup won't be the same and can't be able to access the service installed.
You should try to go to a previous version of your project and uninstall the service and for the future unistall the service each time you're building your setup project.
This happened to me several times.

Run visual studio in debug mode, and in your properties of your service project goto tab build events in Post-Build event command line and add a -d so you can run your service without installing it, it will run as an console app

The LocalService account acts as a non-privileged user on the local computer, and presents anonymous credentials to any remote server. Use the other accounts with caution, as they run with higher privileges and increase your risk of attacks from malicious code.
If your service application will not install correctly, check to make sure that the ServiceName property for the service class is set to the same value as is shown in the installer for that service. The value must be the same in both instances in order for your service to install correctly.
NoteNote
You can also look at the installation logs to get feedback on the installation process.
You should also check to determine whether you have another service with the same name already installed. Service names must be unique for installation to succeed.

STUPIDITY PERSONIFIED
As i told i was deploying my service. So this published code had a "setup.exe" file to it. Now I had already created a setup project for the windows service , which i was using for the installing , uninstalling . And i din't know (These words needs courage !!) that msi file created is required to install the windows service. So as i got through the folder structure of the setup project. I came across the .msi file . And hence the problem got solved. The Main problem was :
Me not knowing to use setup projects
And I confused setup.exe with the published windows service with the setup of windows service.
I am really sorry for stealing bandwidth off your precious time. Thanks to all for the valuable inputs.

Related

Windows service not seen in services even after successful installation

There is one windows service which is installed on one of our servers and working fine.
I tried to replicate the same on the other server, so I took the exe setup from one server to another and tried to install the windows service using installUtil.exe
It is giving me
The Commit phase was completed successfully. The transacted install has been completed.
but the service cannot be found in the services list and it is also giving me this message at the time of installation.
No public installers with the RunInstallerAttribute.Yes, the attribute could be found in the xyz.exe assembly.
Remove InstallState file because there are no installers.
and I am not sure why this is happening? I tried googling but most of them have given the solution to add installer to the project.
But if the installer is not added how the service is running on the first server
is there another way to install the service?
Could it be related to the Windows OS version?

How to Resolve this - Enter an alternate path to a folder containing the installation package

A long time back I developped a Windows service with c# 4.0 and also created a setup file with VS2010 for that app. I installed that app and it was running. someone removed that Windows service not properly like removing some entry from registry regarding that app and as a result that app name is not showing in ADD/Remove list and removed all files and folder from program files folder related to that Windows service.
So when I try to run the setup file for that win service to install it in my pc then I am getting the error message Enter an alternate path to a folder containing the installation package
so guide me how could I again install that Windows service in my pc from that setup. thanks
I've found the "Windows Installer cleanup uitlity" to be enormously helpful in situations like this. It's an abandoned project, but you can still get it by googling. You can use it to completely remove a program from your computer, after which it won't conflict with a new installation.
I found it here:
www.majorgeeks.com
Simply download the file needed and provide the [un]installer with the download folder. And press OK. You can do it without interrupting the process. Do not use the Windows Installer Cleanup Utility It is not supported and extremely dangerous!

Install a service created with VS2010

I've to create a service in Visual Studio for one customer.
The customer IT service indicate me that they don't want any installer, only one exe that can be installed with instsrv.exe.
So I created a Service project on VS2010, compilated it(in 64 bits, it's an application that has to be ran in 64bits).
First problem: I didn't found any instsrv.exe, so I used InstallUtil.exe, the 64 bits version :
C:\Windows\Microsoft.Net\Framework64\v4.0.xxxx\InstallUtil.exe "PathToMyGeneratedExe"
It says me that "The commit phase completed successfully." and "The transacted install has completed.".
So I assume that the install completed successfully.
But if I go in the service console, I can't find the created service.
So what am I missing?
InstallUtil is intended for usage with a service installer (which is really easy to make, but a bit buried) I imagine your client wasnt after a gui installer but I think it may be worth your while putting in the base serviceinstaller.
Normally InstallUtil will also prompt for a user to run the service under as well. if you havent got this you probably arent installed
Take a read of http://arcanecode.com/2007/05/23/windows-services-in-c-adding-the-installer-part-3/ for details of how to do this
(TLDR right click on your service design surface and add installer)

Published application cannot start, but release/debug version starts well

I have a problem when I try to Run published Application. When I Run Release or Debug Version from VS (key F5) everything work well. So I try to publish my application (no problem). After this I Installed application by oneClick installer. Instalation was finished without problem, but when I try to run this installed application, I only see message: Program has Stop Working.
Please, does anybody know where should be a problem? It´s really wierd, I suppose, when the application run correctly from VS, then it Should run after installing to!? Or am I wrong?
Or is there some option to reset Publish settings in Visual Studio?
Thanks a lot!!!
It depends how you have ClickOnce setup, but the main reason this happens is the ClickOnce system encounters an error while checking for updates or running the .application from the remote location.
It should give you the option to see a log of the problem (or at least the nasty temp file it threw it in).
From here you can determine the problem ClickOnce is having.
Most Common Problems I would Suspect:
The User's having trouble communicating thier auth token / credentials to the web server the ClickOnce app is on.
There's another web-related issue downloading the app manifest or .application from the server
Group / Local Policy Problems
Broken install in on local machine's ClickOnce somewhere causing it to have problems overwriting on disk or finding an appropriate location to setup the clickonce package.
Broken install in on local machine's ClickOnce causing a GUID Conflict (I.e. your app and the broken install can't be upgraded, but share the same GUID)
Antivirus / Firewall blocking access to the web component from the executable clickonce deploy.
These are all the problems I've encountered with ClickOnce and the reasons we've primarily moved away from it to a Wix style installer.

Windows Service in C# works on dev machine, crashes in test environment

I have been working on an application using .NET 4 and c# in Visual Studio 2010 Express. It's purpose is to watch a directory and import any documents it finds into our imaging system.
I included an installer class which provides the information needed by installutil.exe.
So to install locally, I build the solution, and then at command line:
installutil.exe MyProjectExecutable.exe
Which installs it as a service. This works fine in my development environment.
To deploy to the test environment, I use the same method:
installutil.exe MyProjectExecutable.exe.deploy
Except of course the executable has a second extension, .deploy. This is the way the application is published by Visual Studio. Everything works up tot his point
Here is the problem: once I have done this, I run the service and it starts properly, as indicated in the log file. However, once it detects files in the directory, the service will not do anything with them and will eventually crash. The only way I can tell it has crashed is to look in the windows Event Viewer. It will show the message:
"An unhandled win32 exception occurred in MyProjectExecutable.exe.deploy [4108]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on."
Two questions:
1) What could be causing this
2) Am I going through the correct steps to install a windows service, or is there a better way?
Both environments have .NET 4 installed.
In both environments I am placing the same documents in the import directory.
In both environments the service runs under the Local System account.
If my question reflects a lack of C# experience, my apologies in advance.
subscribe to AppDomain.UnhandledException Event
Are you watching a directory under 'Documents and Settings?' You mention that you're running under Local System, but is that in the C# code or in the Services Panel?
Start->Run
services.msc
< Find your App >
Right-click, Properties
Log On Tab
Log On As
This Account
< Plug in a user / pass with permissions >
In my experience this it is always a security problem. Check the rights that the service running user has. Can it access the folders you are monitoring and make the needed changes?
I have found the problem. in the config file, the listen directory was "c" whereas it should have been "C". Until now, I didn't think Windows was case-sensitive. Thanks for the help guys.

Categories