473,566 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Configuration of Windows service

I have Windows service MyService, that reads some settings from
MyService.exe.c onfig file via
ConfigurationMa nager.AppSettin gs["Setting_Key_Na me"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.c onfig
from Manager app. I am getting this error:

"System.Configu ration.Configur ationElement.th is[System.Configur ation.Configura tionProperty]'
is inaccessible due to its protection level"

My Manager app has this code to open a service config and read values
from it:

// Open service configuration file
string exePath =
System.IO.Path. Combine(Environ ment.CurrentDir ectory,
"MyService.exe. config");
// Map to the application configuration file.
ExeConfiguratio nFileMap configFile = new
ExeConfiguratio nFileMap();
configFile.ExeC onfigFilename = exePath;
Configuration configServ =
ConfigurationMa nager.OpenMappe dExeConfigurati on(configFile,
ConfigurationUs erLevel.None);
string value = configServ.AppS ettings["CheckUpdateTim eout"];

I can read/write from/to Manager.exe.con fig but looks like it is
prohibited in .NET to work with another app's config files.
Is there a solution to my problem?

Thanks,
Olegus

Mar 5 '07 #1
2 14240
See here:

http://www.eggheadcafe.com/forumpost...umpostid=85647

This is an alternate method to pull info from (~any) config file.


"Olegus" <ol*********@gm ail.comwrote in message
news:11******** **************@ 64g2000cwx.goog legroups.com...
I have Windows service MyService, that reads some settings from
MyService.exe.c onfig file via
ConfigurationMa nager.AppSettin gs["Setting_Key_Na me"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.c onfig
from Manager app. I am getting this error:

"System.Configu ration.Configur ationElement.th is[System.Configur ation.Configu
rationProperty]'
is inaccessible due to its protection level"

My Manager app has this code to open a service config and read values
from it:

// Open service configuration file
string exePath =
System.IO.Path. Combine(Environ ment.CurrentDir ectory,
"MyService.exe. config");
// Map to the application configuration file.
ExeConfiguratio nFileMap configFile = new
ExeConfiguratio nFileMap();
configFile.ExeC onfigFilename = exePath;
Configuration configServ =
ConfigurationMa nager.OpenMappe dExeConfigurati on(configFile,
ConfigurationUs erLevel.None);
string value = configServ.AppS ettings["CheckUpdateTim eout"];

I can read/write from/to Manager.exe.con fig but looks like it is
prohibited in .NET to work with another app's config files.
Is there a solution to my problem?

Thanks,
Olegus

Mar 5 '07 #2
Thanks for your answer, Sloan.

I changed OpenMappedExeCo nfiguration to OpenExeConfigur ation and it
works now. But I have a strong feeling that I use
OpenExeConfigur ation before and it did not work. Hmmmm. Weird.
On Mar 5, 4:49 pm, "sloan" <s...@ipass.net wrote:
See here:

http://www.eggheadcafe.com/forumpost...umpostid=85647

This is an alternate method to pull info from (~any) config file.

"Olegus" <oleg.gus...@gm ail.comwrote in message

news:11******** **************@ 64g2000cwx.goog legroups.com... I have Windows service MyService, that reads some settings from
MyService.exe.c onfig file via
ConfigurationMa nager.AppSettin gs["Setting_Key_Na me"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.c onfig
from Manager app. I am getting this error:

"System.Configu ration.Configur ationElement.th is[System.Configur ation.Configu
rationProperty]'
is inaccessible due to its protection level"
My Manager app has this code to open a service config and read values
from it:
// Open service configuration file
string exePath =
System.IO.Path. Combine(Environ ment.CurrentDir ectory,
"MyService.exe. config");
// Map to the application configuration file.
ExeConfiguratio nFileMap configFile = new
ExeConfiguratio nFileMap();
configFile.ExeC onfigFilename = exePath;
Configuration configServ =
ConfigurationMa nager.OpenMappe dExeConfigurati on(configFile,
ConfigurationUs erLevel.None);
string value = configServ.AppS ettings["CheckUpdateTim eout"];
I can read/write from/to Manager.exe.con fig but looks like it is
prohibited in .NET to work with another app's config files.
Is there a solution to my problem?
Thanks,
Olegus

Mar 5 '07 #3

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

Similar topics

2
7268
by: Fadi | last post by:
Backround: I am trying to figure out how to do the equivalant of a classic COM Local Server Singleton in .NET/C#. I created a coupld of simple Class Libs that exposes public interfaces and hosted them in a Windows Forms EXE. Create a Windows Forms client and both the Client and the Host EXEs configure the remoting protocols through...
5
12274
by: SP | last post by:
Please advice. I am not familiar with the concepts of windows service. I am trying to access a xml configuration file from windows service. But it is failing. configuration file is in the same directory from where I install windows service. I dont want to give an absolute path to the location of file. When I try to start windows service, it...
5
8461
by: Brian Patrick | last post by:
I have an application model which will consist of a front-end configuration application, which needs to control the state of a back-end vb.net windows service (which is the component that does all the work). Think of this in the same manner as say microsoft management console and the w3svc (inetinfo) service. What should the standard...
4
22518
by: PeterW | last post by:
I have a Windows service that needs to get some values from a config file. I place the config file for the service in the System32 directory. I do not get the values using the usual ConfigurationSettings.AppSettings Any tips please cheers -- PeterW
2
3888
by: mma | last post by:
hello everyone, i have a solution that contains the following project types: 1. Class library contains a singleton class that handles the data access (sql server 2005). 2. Windows service. uses the Class library's singleton class to manipulate data in the data base server. 3. Windows application.
1
5416
by: noah.blumenthal | last post by:
I wrote a windows service in c# (applause) and now I want to add the ability to edit its settings. Basically this service checks an email account at certain intervals and forwards the emails to another email address. I want to be able to configure how often it runs (it uses a timer, so setting the interval for that timer is what I mean by...
1
6421
by: Karch | last post by:
I am writing a WCF Service using MSMQ hosted in a Windows Service on Windows XP. All the required components are installed (.NET3, MSMQ, etc). For some reason my service tries to start and then stops right away. I have looked at everything and can't see anything wrong - in fact, I started this a few weeks ago and I swear it was running at...
0
8261
by: =?Utf-8?B?QWRyaWFuIENvbGU=?= | last post by:
I have written a simple WCF service hosted in a Windows console application and a simple WCF client console application that connects successfully to that service and retrieves data. I then ported the console application to WinForms and also got that to work properly. My next move was to host the WCF service in a Windows service application....
5
3283
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?
0
7584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8109
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...
0
6263
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
5485
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
5213
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
3643
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
926
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.