473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ 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" ?>

<configuratio n>

<appSettings>

<add key="StringName " value="StringVa lue" />

</appSettings>

</configuration>

//Code in the service installer

str=System.Conf iguration.Confi gurationSetting s.AppSettings["StringName "];

this.serviceIns taller1.Service Name=str;

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

An exception occurred during the Install phase.

System.Argument Exception: 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 14140
Hello

The config file should have the name filename.exe.co nfig, 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*******@egds c.microsoft.com > wrote in message
news:eq******** ******@TK2MSFTN GP09.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" ?>

<configuratio n>

<appSettings>

<add key="StringName " value="StringVa lue" />

</appSettings>

</configuration>

//Code in the service installer

str=System.Conf iguration.Confi gurationSetting s.AppSettings["StringName "];

this.serviceIns taller1.Service Name=str;

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

An exception occurred during the Install phase.

System.Argument Exception: 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.publi c.dotnet.langua ges.csharp , "Rami Saad"
<ra*******@egds c.microsoft.com > wrote:
Hi all,

I am trying to install a service using dynamic naming. I wrote values in the
configuratio n 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.GetExe cutingAssembly( );
FileInfo fi = new FileInfo(curren tAsm.Location);
DirectoryInfo runFolder = fi.Directory;
string prefix = "";
foreach (FileInfo extFi in
runFolder.GetFi les("ServiceNam e.*")) {
prefix =
extFi.Extension .Replace(".","" ).ToUpper();
}
return prefix;
}
}

public ProjectInstalle r() {
// This call is required by the Designer.
InitializeCompo nent();
string serviceName = this.ServicePre fix
+ this.serviceIns taller1.Service Name;
Console.Write(" ServiceName is " + serviceName + " (enter to
continue) ");
Console.ReadLin e();
this.serviceIns taller1.Display Name = 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
1687
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 of the installer <?xml version="1.0" encoding="utf-8" ?>
9
7029
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 sample, it provides the feature to install service under LocalSystem account. What I need is to install service under some other certian account. By further studying the code, and MSDN...
5
2698
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 Administration group (on server side) to have the necessary authorization to start a Windows Service (I don't understand why "Power User" rights are not enough to do the same thing) Although I'm able to start a service using windows 2000 server...
15
2068
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 contained details of it's whereabouts, I have been looking at the "Discovery.DynamicDiscoveryDocument" class but I think think this is what I am looking for is it? Thanks in advance. Nick.
3
14958
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 swLog As StreamWriter = File.CreateText("C:\myLog.txt") swLog.WriteLine("My Windows Service has just started.") swLog.Close() : swLog.Flush() End Sub
0
2699
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 to whether my solution is robust or whether there is a better way to do it. What I've been trying to do is to create a core project with different extension projects, one for each customer. I wanted to create a different Setup project for each...
5
3309
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? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
1
4400
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 windows service. I have already tried the following and have not achieved success til yet 1) Loading the Assembly (DLL) containing the DDE Client using AppDomain.Load / Assembly.Load 2) Loading a DDE Client (console app) using...
1
1751
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
10373
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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 we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.