yizchaknaveh
asked on
Setting up dependencies in a Windows Service?
When I create an installer for a Windows Service (with Visual Studio), how can I set up dependencies?
For instance, dependencies on other services?
Thanks!
For instance, dependencies on other services?
Thanks!
ASKER
Maybe in some cases.
But let's say my service relies on SQL Server running locally (because I have ADO.NET that assumes that).
How do I register that implicit dependency?
But let's say my service relies on SQL Server running locally (because I have ADO.NET that assumes that).
How do I register that implicit dependency?
From a book I have on C#:
ServiceInstaller is the class needed for every service; it has the following propeties for each service inside a process:
StartType
DisplayName
ServiceName
and ( I think this is the one you want )
ServicesDependedOn
ServicesDependedOn -- Specifies an array of services that MUST be started before this service can be started. When the service is started, all these dependent services are started automatically, and then our service will start.
Does this help you?
Tom
ServiceInstaller is the class needed for every service; it has the following propeties for each service inside a process:
StartType
DisplayName
ServiceName
and ( I think this is the one you want )
ServicesDependedOn
ServicesDependedOn -- Specifies an array of services that MUST be started before this service can be started. When the service is started, all these dependent services are started automatically, and then our service will start.
Does this help you?
Tom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am getting all of this information from the following book:
Professional C# 3rd Edition (by Wrox Publishing)
Professional C# 3rd Edition (by Wrox Publishing)
This all starts on page 1112 in the above-mentioned book.
Sorry to be so psycho....but this is from the Help documentation for .NET:
.ServicesDependedOn Property [C#]See Also
ServiceInstaller Class | ServiceInstaller Members | System.ServiceProcess Namespace | StartType | ServiceInstaller Members (Visual J# Syntax) | Managed Extensions for C++ Programming
Requirements
Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
Language
C#
C++
JScript
Visual Basic
Show All
Indicates the services that must be running for this service to run.
[Visual Basic]
Public Property ServicesDependedOn As String ()
[C#]
public string[] ServicesDependedOn {get; set;}
[C++]
public: __property String* get_ServicesDependedOn();
public: __property void set_ServicesDependedOn(Str ing* __gc[]);
[JScript]
public function get ServicesDependedOn() : String[];
public function set ServicesDependedOn(String[ ]);
Property Value
An array of services that must be running before the service associated with this installer can run.
Remarks
A service can require other services to be running before it can start. The information from this property is written to a key in the registry. When the user (or the system, in the case of automatic startup) tries to run the service, the Service Control Manager (SCM) verifies that each of the services in the array has already been started.
If any service in the array is not running then, the SCM tries to start them. This includes services with Manual StartType.
If any service upon which this service depends fails to start, this service will not start. An exception is not thrown if the system is not started because there is no exception handling at the system level to detect this. Decide how to handle service start failures and implement this in your code. Typically, a dialog appears to the user at startup if a service fails to start.
If the service does not start, an entry is written to the Application event log.
The services upon which this service depends do not need to be in the same executable.
Requirements
Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
See Also
ServiceInstaller Class | ServiceInstaller Members | System.ServiceProcess Namespace | StartType | ServiceInstaller Members (Visual J# Syntax) | Managed Extensions for C++ Programming
Syntax based on .NET Framework version 1.1.
.ServicesDependedOn Property [C#]See Also
ServiceInstaller Class | ServiceInstaller Members | System.ServiceProcess Namespace | StartType | ServiceInstaller Members (Visual J# Syntax) | Managed Extensions for C++ Programming
Requirements
Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
Language
C#
C++
JScript
Visual Basic
Show All
Indicates the services that must be running for this service to run.
[Visual Basic]
Public Property ServicesDependedOn As String ()
[C#]
public string[] ServicesDependedOn {get; set;}
[C++]
public: __property String* get_ServicesDependedOn();
public: __property void set_ServicesDependedOn(Str
[JScript]
public function get ServicesDependedOn() : String[];
public function set ServicesDependedOn(String[
Property Value
An array of services that must be running before the service associated with this installer can run.
Remarks
A service can require other services to be running before it can start. The information from this property is written to a key in the registry. When the user (or the system, in the case of automatic startup) tries to run the service, the Service Control Manager (SCM) verifies that each of the services in the array has already been started.
If any service in the array is not running then, the SCM tries to start them. This includes services with Manual StartType.
If any service upon which this service depends fails to start, this service will not start. An exception is not thrown if the system is not started because there is no exception handling at the system level to detect this. Decide how to handle service start failures and implement this in your code. Typically, a dialog appears to the user at startup if a service fails to start.
If the service does not start, an entry is written to the Application event log.
The services upon which this service depends do not need to be in the same executable.
Requirements
Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
See Also
ServiceInstaller Class | ServiceInstaller Members | System.ServiceProcess Namespace | StartType | ServiceInstaller Members (Visual J# Syntax) | Managed Extensions for C++ Programming
Syntax based on .NET Framework version 1.1.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
I ended up using heintalus' suggestion, but learned a lot from knowlton's in-depth efforts.
Points split.
I ended up using heintalus' suggestion, but learned a lot from knowlton's in-depth efforts.
Points split.
Thanks!!! Have fun?
::: listening ::::