473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 SearchMgrService...
Service SearchMgrService has been successfully installed.
Creating EventLog source SearchMgrService 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.exe -install"

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Configuration;
using System.Configuration.Install;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.Win32;

public class TestService : System.ServiceProcess.ServiceBase
{
private System.ComponentModel.Container components = null;

public TestService()
{
InitializeComponent();
}

static void Main( string[] startArgs )
{
string serviceName = "TestService";
try
{
string startOptions = null;
if ( startArgs.Length > 0 )
{
startOptions = startArgs[0].Trim();
}

string assemLocation =
System.Reflection.Assembly.GetExecutingAssembly(). Location.ToLower();

if ( startOptions != null && startOptions.ToLower() ==
"-install" )
{
System.Configuration.Install.TransactedInstaller
transInstaller = new TransactedInstaller();
TestServiceInstaller svcInstaller = new
TestServiceInstaller();
transInstaller.Installers.Add( svcInstaller );
string[] cmdLine = { "/assemblypath=" + assemLocation };
System.Configuration.Install.InstallContext instContext = new
InstallContext( assemLocation.Replace(".exe",".txt") , cmdLine ) ;
transInstaller.Context = instContext ;
transInstaller.Install( new Hashtable() );

System.Windows.Forms.MessageBox.Show( assemLocation );

Microsoft.Win32.RegistryKey regKey = Registry.LocalMachine;
try
{
RegistryKey serviceKey = regKey.OpenSubKey(
"System\\CurrentControlSet\\Services\\TestServ ice" , true
);
serviceKey.SetValue( "Description" ,
"Remoting communication manager/interface for local Cisvc
catalogs." );
serviceKey.SetValue( "Type" , "272" );
serviceKey.Close();
}
catch( Exception svcXxx )
{
System.Windows.Forms.MessageBox.Show( svcXxx.ToString() );
}
finally
{
regKey.Close();
}
}
if ( startOptions != null && startOptions.ToLower() == "-remove"
)
{
System.Configuration.Install.TransactedInstaller
transInstaller = new TransactedInstaller();
TestServiceInstaller svcInstaller = new
TestServiceInstaller();
transInstaller.Installers.Add( svcInstaller );
String assemPath = String.Format( "/assemblypath=" +
System.Reflection.Assembly.GetExecutingAssembly(). Location )
;
String[] cmdLine = { assemPath };
InstallContext instContext = new InstallContext( "", cmdLine
);
transInstaller.Context = instContext ;
transInstaller.Uninstall( null );
}
}
catch( Exception xxx )
{
System.Windows.Forms.MessageBox.Show( xxx.ToString() );
}

System.ServiceProcess.ServiceBase[] ServicesToRun =
new System.ServiceProcess.ServiceBase[] { new TestService() };

System.ServiceProcess.ServiceBase.Run(ServicesToRu n);
}

private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "TestService";
this.CanHandlePowerEvent = false;
this.CanPauseAndContinue = false;
this.CanShutdown = true;
this.CanStop = true;
this.AutoLog = true;
}

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

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

protected override void OnStop()
{

}
}


//[RunInstaller(true)]
public class TestServiceInstaller :
System.Configuration.Install.Installer
{
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;

public TestServiceInstaller()
{
processInstaller = new ServiceProcessInstaller();
processInstaller.Account = ServiceAccount.LocalSystem;

serviceInstaller = new ServiceInstaller();
serviceInstaller.ServiceName = "TestService";
serviceInstaller.DisplayName = "Test Service";
serviceInstaller.StartType = ServiceStartMode.Automatic;

this.Installers.Add(processInstaller);
this.Installers.Add(serviceInstaller);
}
}

tia

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

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

Similar topics

3
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,...
2
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...
11
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: ...
2
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...
10
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...
0
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...
1
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...
0
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.