Configuration problem ( very urgent )

G

Guest

I'm developing a web application i.e. asp.net. I have added a key named
"Provider" in web.config file as follows

<appSettings>
<add key="Provider" value="3"></add>
<add key="OracleClient" value="data source=global;user
id=atms_user;password=sql"></add>
<add key="Connection" value="server=global;user
Id=atms_user;password=sql"></add>
</appSettings>

And while coding when I wanted to retrive the provider as below
string provider = ConfigurationSettings.AppSettings["Provider"];

the application is giving the following error
Error loading XML file
c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config Request for
the permission of type
System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
(c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config)


It seems that application instead of getting the key from web.config i think
it is trying to get from machine.config

Please respond me as soon as possible

thanks in advance
 
R

Richard Grimes [MVP]

Sai Pavan said:
I'm developing a web application i.e. asp.net. I have added a key named
"Provider" in web.config file as follows

<appSettings>
<add key="Provider" value="3"></add>
<add key="OracleClient" value="data source=global;user
id=atms_user;password=sql"></add>
<add key="Connection" value="server=global;user
Id=atms_user;password=sql"></add>
</appSettings>

And while coding when I wanted to retrive the provider as below
string provider = ConfigurationSettings.AppSettings["Provider"];

the application is giving the following error
Error loading XML file
c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config Request
for
the permission of type
System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed.
(c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config)


It seems that application instead of getting the key from web.config i
think
it is trying to get from machine.config


It will always read machine.config first (to get the default values for
<appSettings> for every app on the machine) and then it will read web.config
afterwards overwriting the defaults from machine.config if necessary. This
is the way that its designed to work.

The question is why you get the error loading machine.config. Do you have
any custom Code Access Security permissions?

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top