473,813 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read Machine.Config

Hi -
I'm trying to manually read and parse Machine.Config. When I try this I
recieve the following error:
Access to the path "C:\WINDOWS\Mic rosoft.NET\Fram ework\v1.1.4322 \" is
denied.

I am doing this by first getting the directory location of the framework and
passing it to a DirectoryInfo object. I can then use this object to move to
the Config folder. I suspect I only need to demand a permission in my code
but I'm not quite sure how to go about it. Unfortunately - using the built
in .NET methods to read .config files won't work for what I am doing so
accessing machine.config from my C# code is a must. Thanks!

Brian

---------<snip>---------

DirectoryInfo di = new
DirectoryInfo(S ystem.Runtime.I nteropServices. RuntimeEnvironm ent.GetRuntimeD irectory());

di.MoveTo("CONF IG");

Nov 16 '05 #1
1 2991
Brian Patterson wrote:
Hi -
I'm trying to manually read and parse Machine.Config. When I try
this I recieve the following error:
Access to the path "C:\WINDOWS\Mic rosoft.NET\Fram ework\v1.1.4322 \" is
denied.

I am doing this by first getting the directory location of the
framework and passing it to a DirectoryInfo object. I can then use this
object to
move to the Config folder. I suspect I only need to demand a permission
in
my code but I'm not quite sure how to go about it. Unfortunately - using
the
built in .NET methods to read .config files won't work for what I am doing
so accessing machine.config from my C# code is a must. Thanks!


Basically, you're not intended to do this. Instead the expected mechanism is
to use ConfigurationSe ttings.GetConfi g, but some sections will be excluded
from your access, and anyway the application config settings will override
any machine settings.

If you really do need access to machine.conf as a text file then you should
get the administrator to change the ACLs on the file (and/or folder).
However, there's a reason why those ACLs are applied and hence its not
always a good idea to change them.

So that lead to the question, why do you want to have direct access to
machine.config?

Richard
--
www.richardgrimes.com
my email ev******@zicf.b et is encrypted with ROT13 (www.rot13.org)
Nov 16 '05 #2

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

Similar topics

9
3008
by: Marina Anufreichik | last post by:
Hi, After deploymnet web application on web server I can access page on local machine and login fine but when I'm trying to access web site from remote machine I can see login page, but when I'm trying to login with correct credentials it give me error: Server Error in '/PDVMgr' Application. ----------------------------------------------------------------------------
7
6579
by: | last post by:
In the beginning we had Ini files. Later we had registery files. Now have xml files and our read-only myapp.config file. My question now, is what is the best way to store and load user and machine specific settings for a .NET program? And what classes, or code do we have to do this in C#? I don't think that using the myapp.config is the best choice to store since the file might be read-only if the program is started from a CD ROM, or...
1
5363
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; Anybody able to give me idea how-to read by C# element which I add to the machine.config into the new single section?
4
3002
by: Chris V | last post by:
I'm having a problem deploying my ASP.NET application to a WIN2k server. (IIS5 .NET 1.1) When I try to access ConfigurationSettings.AppSettings("WhateverValue") I get an "Object reference not set to an instance of an object." message I thought this may have been to do with Virtual Directory settings but I've got the folder set as an application in IIS and asp.net is installed and working. My web.config file is Not Marked read-only and...
7
3351
by: Bob | last post by:
It's great that VS.NET makes it so effortless to add a web reference to a web service. The problem is, I haven't figured out a way to configure the URLs (or simply switch the references to another web reference) easily when I move my app from development, to staging, to production, as I have corresponding environments for the web services too. So far what I have done is copying the Reference.cs file out and creating a separate class by...
4
12151
by: Josema | last post by:
Hi to all, Im searching a hand to solve an Exception that i get when i try to give the user to a gmail account... Any help would be appreciated.. Thanks in advance This is a piece of my code: Server=new TcpClient("pop.gmail.com",995); //stablish a connection
2
3504
by: Max Metral | last post by:
I'm trying to set the default behavior of customErrors in the machine.config. The documentation seems to suggest this should work, but it doesn't seem to work for me. On my development machine, I want customErrors off, and on my production machine I want them to go to a friendly error page (so on with a defaultRedirect). No matter what I do, I only get "customErrors off" with setting in machine.config and not web.config. Any thoughts?...
4
2314
by: klynn | last post by:
Hi: I'm having problems reading a Microsoft Access file from my ASP.Net app on a Windows Server 2003 machine. The error message: The Microsoft database engine cannot open the file, <my_file>. It is already opened exclusively by another user, or you need permission to view its data. I've read some info about this (microsoft support article q316675) but I'm still confused on what to do?
2
1841
by: =?Utf-8?B?U2JhdGNodQ==?= | last post by:
How will i read connection strings in all web.config files in one particualr machine?
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10422
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
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
9222
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
7681
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
6897
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5705
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
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
3885
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.