473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dynamic windows service name

Hi all,

I am trying to install a service using dynamic naming. I wrote values in the
configuration file, and trying to assign one of those values to a string,
and using this string as the name of the installer

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="StringName" value="StringValue" />

</appSettings>

</configuration>

//Code in the service installer

str=System.Configuration.ConfigurationSettings.App Settings["StringName"];

this.serviceInstaller1.ServiceName=str;

when using the installutil tool, I get the following exception:

An exception occurred during the Install phase.

System.ArgumentException: Must specify value for source.

Usually, if I write the string value in a normal text file, and read the
value from the file while installing (instead of reading from the
appSettings element) I don't get any exceptions and it works fine..

So what could be the reason then? and normally how can you set a dynamic
service name using the configuration file?

Thank you for your help
--
Rami Saad
Microsoft GTSC Developer support for Middle East

Nov 15 '05 #1
2 14092
Hello

The config file should have the name filename.exe.config, and must be in the
same directory as the executable file. Since you are using .NET framework's
installutil.exe to install your service. In this case, you must name the
file installutil.exe.config and put it in the .NET framework folder under
the system directory. This is not practical of course.

Best regards,
Sherif

"Rami Saad" <ra*******@egdsc.microsoft.com> wrote in message
news:eq**************@TK2MSFTNGP09.phx.gbl...
Hi all,

I am trying to install a service using dynamic naming. I wrote values in the configuration file, and trying to assign one of those values to a string,
and using this string as the name of the installer

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="StringName" value="StringValue" />

</appSettings>

</configuration>

//Code in the service installer

str=System.Configuration.ConfigurationSettings.App Settings["StringName"];

this.serviceInstaller1.ServiceName=str;

when using the installutil tool, I get the following exception:

An exception occurred during the Install phase.

System.ArgumentException: Must specify value for source.

Usually, if I write the string value in a normal text file, and read the
value from the file while installing (instead of reading from the
appSettings element) I don't get any exceptions and it works fine..

So what could be the reason then? and normally how can you set a dynamic
service name using the configuration file?

Thank you for your help
--
Rami Saad
Microsoft GTSC Developer support for Middle East

Nov 15 '05 #2
On Mon, 1 Mar 2004 17:16:07 +0200 in article
<eq**************@TK2MSFTNGP09.phx.gbl> in
microsoft.public.dotnet.languages.csharp , "Rami Saad"
<ra*******@egdsc.microsoft.com> wrote:
Hi all,

I am trying to install a service using dynamic naming. I wrote values in the
configuration file, and trying to assign one of those values to a string,
and using this string as the name of the installer


Sherif has told you why that won't work. What I do for that is:
private string ServicePrefix {
get {
Assembly currentAsm = Assembly.GetExecutingAssembly();
FileInfo fi = new FileInfo(currentAsm.Location);
DirectoryInfo runFolder = fi.Directory;
string prefix = "";
foreach (FileInfo extFi in
runFolder.GetFiles("ServiceName.*")) {
prefix =
extFi.Extension.Replace(".","").ToUpper();
}
return prefix;
}
}

public ProjectInstaller() {
// This call is required by the Designer.
InitializeComponent();
string serviceName = this.ServicePrefix
+ this.serviceInstaller1.ServiceName;
Console.Write("ServiceName is " + serviceName + " (enter to
continue) ");
Console.ReadLine();
this.serviceInstaller1.DisplayName = serviceName;
}

This looks for a file called ServiceName.* in the same folder as the
Service's exe and whatever the * translates to is used as the prefix
of the service name as set at design time.

This allows me to have multiple copies of my service running on the
same machine.
--
Simon
simon dot s at ghytred dot com
"If you're using slower-than-light travel, you can just pack the ship
with cloned dinosaurs and convert them to petroleum along the way..." (M.Ruff)
Nov 15 '05 #3

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

Similar topics

0
by: Rami Saad | last post by:
Hi all, I am trying to install a service using dynamic naming. I wrote values in the configuration file, and trying to assign one of those values to a string, and using this string as the name...
9
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code...
5
by: pberna | last post by:
Dear all, I built a Web Form application to start and stop a Windows Service remotely. I successful tested the application on Windows 2000 server + IIS. I must include the ASPNET user to the...
15
by: Nak | last post by:
Hi there, Is it possible to load a web service dynamically? i.e. If the web service were to exist on a system with a non static IP address, an application could download a "locator" file that...
3
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim...
0
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi All I would like to install the same Windows Service project on the same server under different names, one for each customer. I have been able to do it but I would like an expert opinion as...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
1
by: sutch | last post by:
I have created a DDE( Dynamic-Data Exchange) Client (Console) application to interact with a legacy DDE Server. This client is working perfectly I am asked to develop same functionality in a...
1
by: syed anwar | last post by:
I want to invoke client machine Windows Service over internet from WebServer . I have kept the client credential :( IP , Machine Name and Windows Service Name) so how can we invoke the service ?
0
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,...
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
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...
1
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...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.