473,385 Members | 1,919 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,385 software developers and data experts.

Configuration of Windows service

I have Windows service MyService, that reads some settings from
MyService.exe.config file via
ConfigurationManager.AppSettings["Setting_Key_Name"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.config
from Manager app. I am getting this error:

"System.Configuration.ConfigurationElement.thi s[System.Configuration.ConfigurationProperty]'
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(Environment.CurrentDirector y,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(co nfigFile,
ConfigurationUserLevel.None);
string value = configServ.AppSettings["CheckUpdateTimeout"];

I can read/write from/to Manager.exe.config 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 14222
See here:

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

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


"Olegus" <ol*********@gmail.comwrote in message
news:11**********************@64g2000cwx.googlegro ups.com...
I have Windows service MyService, that reads some settings from
MyService.exe.config file via
ConfigurationManager.AppSettings["Setting_Key_Name"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.config
from Manager app. I am getting this error:

"System.Configuration.ConfigurationElement.thi s[System.Configuration.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(Environment.CurrentDirector y,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(co nfigFile,
ConfigurationUserLevel.None);
string value = configServ.AppSettings["CheckUpdateTimeout"];

I can read/write from/to Manager.exe.config 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 OpenMappedExeConfiguration to OpenExeConfiguration and it
works now. But I have a strong feeling that I use
OpenExeConfiguration before and it did not work. Hmmmm. Weird.
On Mar 5, 4:49 pm, "sloan" <s...@ipass.netwrote:
See here:

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

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

"Olegus" <oleg.gus...@gmail.comwrote in message

news:11**********************@64g2000cwx.googlegro ups.com...I have Windows service MyService, that reads some settings from
MyService.exe.config file via
ConfigurationManager.AppSettings["Setting_Key_Name"]. I tried to write
small WinForm frontend app(called it Manager.exe) to manage settings
of MyService, but have problems with accessing MyService.exe.config
from Manager app. I am getting this error:

"System.Configuration.ConfigurationElement.thi s[System.Configuration.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(Environment.CurrentDirector y,
"MyService.exe.config");
// Map to the application configuration file.
ExeConfigurationFileMap configFile = new
ExeConfigurationFileMap();
configFile.ExeConfigFilename = exePath;
Configuration configServ =
ConfigurationManager.OpenMappedExeConfiguration(co nfigFile,
ConfigurationUserLevel.None);
string value = configServ.AppSettings["CheckUpdateTimeout"];
I can read/write from/to Manager.exe.config 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
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...
5
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...
5
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...
4
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...
2
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....
1
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...
1
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...
0
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...
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?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.