473,568 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Service Transacted Installation Problem

poi


Running the code below, I get the error

Cannot start service from the command line opr debugger. A Windows
Service must first be installed (using installutil.exe ) and then started
with the ServerExplorer. ....
But the text log from my install shows this:

Running a transacted installation.

Beginning the Install phase of the installation.
Installing service SearchMgrServic e...
Service SearchMgrServic e has been successfully installed.
Creating EventLog source SearchMgrServic e in log Application...

The Install phase completed successfully, and the Commit phase is
beginning.

The Commit phase completed successfully.

The transacted install has completed.

But still the service will not start! I get errors in the event log as
well.

Below is the code, run with "testservice.ex e -install"

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Diagnost ics;
using System.ServiceP rocess;
using System.Configur ation;
using System.Configur ation.Install;
using System.Runtime. InteropServices ;
using System.Windows. Forms;
using Microsoft.Win32 ;

public class TestService : System.ServiceP rocess.ServiceB ase
{
private System.Componen tModel.Containe r components = null;

public TestService()
{
InitializeCompo nent();
}

static void Main( string[] startArgs )
{
string serviceName = "TestServic e";
try
{
string startOptions = null;
if ( startArgs.Lengt h > 0 )
{
startOptions = startArgs[0].Trim();
}

string assemLocation =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location.T oLower();

if ( startOptions != null && startOptions.To Lower() ==
"-install" )
{
System.Configur ation.Install.T ransactedInstal ler
transInstaller = new TransactedInsta ller();
TestServiceInst aller svcInstaller = new
TestServiceInst aller();
transInstaller. Installers.Add( svcInstaller );
string[] cmdLine = { "/assemblypath=" + assemLocation };
System.Configur ation.Install.I nstallContext instContext = new
InstallContext( assemLocation.R eplace(".exe"," .txt") , cmdLine ) ;
transInstaller. Context = instContext ;
transInstaller. Install( new Hashtable() );

System.Windows. Forms.MessageBo x.Show( assemLocation );

Microsoft.Win32 .RegistryKey regKey = Registry.LocalM achine;
try
{
RegistryKey serviceKey = regKey.OpenSubK ey(
"System\\Curren tControlSet\\Se rvices\\TestSer vice" , true
);
serviceKey.SetV alue( "Descriptio n" ,
"Remoting communication manager/interface for local Cisvc
catalogs." );
serviceKey.SetV alue( "Type" , "272" );
serviceKey.Clos e();
}
catch( Exception svcXxx )
{
System.Windows. Forms.MessageBo x.Show( svcXxx.ToString () );
}
finally
{
regKey.Close();
}
}
if ( startOptions != null && startOptions.To Lower() == "-remove"
)
{
System.Configur ation.Install.T ransactedInstal ler
transInstaller = new TransactedInsta ller();
TestServiceInst aller svcInstaller = new
TestServiceInst aller();
transInstaller. Installers.Add( svcInstaller );
String assemPath = String.Format( "/assemblypath=" +
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location )
;
String[] cmdLine = { assemPath };
InstallContext instContext = new InstallContext( "", cmdLine
);
transInstaller. Context = instContext ;
transInstaller. Uninstall( null );
}
}
catch( Exception xxx )
{
System.Windows. Forms.MessageBo x.Show( xxx.ToString() );
}

System.ServiceP rocess.ServiceB ase[] ServicesToRun =
new System.ServiceP rocess.ServiceB ase[] { new TestService() };

System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
}

private void InitializeCompo nent()
{
components = new System.Componen tModel.Containe r();
this.ServiceNam e = "TestServic e";
this.CanHandleP owerEvent = false;
this.CanPauseAn dContinue = false;
this.CanShutdow n = true;
this.CanStop = true;
this.AutoLog = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

protected override void OnStart(string[] args)
{
TestHost testHost = new TestHost();
testHost.Listen ();
}

protected override void OnStop()
{

}
}


//[RunInstaller(tr ue)]
public class TestServiceInst aller :
System.Configur ation.Install.I nstaller
{
private ServiceInstalle r serviceInstalle r;
private ServiceProcessI nstaller processInstalle r;

public TestServiceInst aller()
{
processInstalle r = new ServiceProcessI nstaller();
processInstalle r.Account = ServiceAccount. LocalSystem;

serviceInstalle r = new ServiceInstalle r();
serviceInstalle r.ServiceName = "TestServic e";
serviceInstalle r.DisplayName = "Test Service";
serviceInstalle r.StartType = ServiceStartMod e.Automatic;

this.Installers .Add(processIns taller);
this.Installers .Add(serviceIns taller);
}
}

tia

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
0 1653

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1081
by: TT (Tom Tempelaere) | last post by:
Hi there I am making a service project in C#, and I'm in the process of writing the installer. I made an installer class by using the "Add Installer" menu-item in the design window of the service, then I configured the properties of the installers When I run InstallUtil on the executable, it fails with the following message "An exception...
2
21870
by: Mark | last post by:
I created an extremely simple windows service that only writes to the EventLogs on Stop and Pause. I installed it using the InstallUtil.exe program, the output of which is below. It appears to be successful. I'm now ready to start my service (I think) but the NET START command does not appear to indicate that the service is available to be...
11
5693
by: tshad | last post by:
I have a small Windows Service program that just has a timer on it and it built fine. I try to install it using InstallUtil and I get the following message: System.ComponentModel.Win32Exception: The account name is invalid or does not exist, or the password is invalid for the account name specified I am in the same folder my program is...
2
1600
by: J | last post by:
hi, I'm having a problem installing a service created in vb.net 2003 on a windows 2000 server. I have installed the service on a few XP machines with out any problems...but the 2 servers (win 2000 server sp4) I have triend have the same error (both are on diffrent domains and have framework v1.1 installed; 1 is a domain controler, the other...
10
1327
by: apondu | last post by:
Hi, I am trying to write a windows service using the option that is present ..Net. I am using the window service project. I have written a simple window service and even created a installer for tht by using the option present in widow service. When i try to execute the window service using installutil.exe i get this exception Exception...
0
1548
by: Waldy | last post by:
Hi there, I have written a C# service that self installs by running the ..exe with a parameter. A log is produced when it does this. At a customer site where they have had to re-install, they are getting an error. See the log file below. It fails because the name already exists, but then fails to uninstall because it does not exist! ...
1
9951
by: jobs | last post by:
Seems like I followed all steps but I can't find my service in the service manager?? f:\windowsservice\EmptyService\EmptyService\bin\Debug>InstallUtil EmptyS ervice.exe Microsoft (R) .NET Framework Installation utility Version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved.
0
1332
by: sklett | last post by:
I've created a service project. Added installer classes. Ran InstallUtil /i from the .net 2.0 path IE: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 I've been googling this problem and can't get it sorted. Here is the output from Installutil: <snip> C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>installutil.exe /i "C:\Program Files\x\NS...
0
1032
by: Sid Price | last post by:
I am writing a service using VB.NET 2005 and having some trouble getting started. I sued the wizard to create the service and I have added some code to the "OnStart" method. Using the technique described in "How to: Debug the OnStart Method" I have debugged my startup code and it appears to be working the way I want. Now I want to install the...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.