G
Guest
Hi,
I am trying to use machine.config to store database settings for a
connection wrapper class I am using as part of the data layer of an n-tier
system.
Have added the following section to my machine.config file
<appSettings>
<add key ="iSpexDatabaseType" value ="SQL"/>
<add key ="iSpexServer" value ="DEVANS1"/>
<add key ="iSpexUserID" value ="sa"/>
<add key ="iSpexPassword" value ="[password]"/>
<add key ="iSpexDatabase" value ="ISPEX"/>
</appSettings>
To access this I have the following C# code:
Configuration config = ConfigurationManager.OpenMachineConfiguration();
dbType = config.AppSettings["iSpexDatabaseType"];
server = config.AppSettings["iSpexServer"];
uid = config.AppSettings["iSpexUserID"];
pwd = config.AppSettings["iSpexPassword"];
db = config.AppSettings["iSpexDatabase"];
I am getting the following compile error on each of the latter 5 lines of
code:
Error 1 'System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty]'
is inaccessible due to its protection level
C:\iSpex\SPXDatabaseSettings.root\SPXDatabaseSettings\SPXDatabaseSettings\Settings.cs 24 22 SPXDatabaseSettings
Reading around, I suspect this to be a security error of some sort, perhaps
connected with access to the machine.config file. Though if it is a security
problem, I would have thought it would have produced a run-time error, not a
compile error. Is this a matter of changing the security on the
machine.config file? If so, how can I assign the relevant privleges to an
incomplete assembly that is still being developed, and therefore cannot yet
be assigned to the GAC?
Cheers
Ian
I am trying to use machine.config to store database settings for a
connection wrapper class I am using as part of the data layer of an n-tier
system.
Have added the following section to my machine.config file
<appSettings>
<add key ="iSpexDatabaseType" value ="SQL"/>
<add key ="iSpexServer" value ="DEVANS1"/>
<add key ="iSpexUserID" value ="sa"/>
<add key ="iSpexPassword" value ="[password]"/>
<add key ="iSpexDatabase" value ="ISPEX"/>
</appSettings>
To access this I have the following C# code:
Configuration config = ConfigurationManager.OpenMachineConfiguration();
dbType = config.AppSettings["iSpexDatabaseType"];
server = config.AppSettings["iSpexServer"];
uid = config.AppSettings["iSpexUserID"];
pwd = config.AppSettings["iSpexPassword"];
db = config.AppSettings["iSpexDatabase"];
I am getting the following compile error on each of the latter 5 lines of
code:
Error 1 'System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty]'
is inaccessible due to its protection level
C:\iSpex\SPXDatabaseSettings.root\SPXDatabaseSettings\SPXDatabaseSettings\Settings.cs 24 22 SPXDatabaseSettings
Reading around, I suspect this to be a security error of some sort, perhaps
connected with access to the machine.config file. Though if it is a security
problem, I would have thought it would have produced a run-time error, not a
compile error. Is this a matter of changing the security on the
machine.config file? If so, how can I assign the relevant privleges to an
incomplete assembly that is still being developed, and therefore cannot yet
be assigned to the GAC?
Cheers
Ian