473,387 Members | 3,787 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,387 software developers and data experts.

Error referencing key value from web.config.

Hi,
I have a web application which internally calls certain web methods of
a web service. This web service has a interop to ATL COM Component and
that ATL component calls a .NET assembly.
I would like to access a key value in the .NET assembly. I added this
to the Web.Config of the Web Service however it didnt read the value.
I also tried adding to the Web.config of the Web application however i
am faced with the same problem.

Am I missing any configuration to get this working

Cheers
Prabu

Sep 18 '06 #1
3 1902
Hi Prabu,

How do you configure web.config?

If you put a key under appSettings you can read it using the
ConfigurationManager.

//web.config
<add key="Mykey" value="MyValue" />

//code
string myKey = ConfigurationManager.AppSettings["MyKey"];

On Mon, 18 Sep 2006 10:55:40 +0200, <pr*************@gmail.comwrote:
Hi,
I have a web application which internally calls certain web methods of
a web service. This web service has a interop to ATL COM Component and
that ATL component calls a .NET assembly.
I would like to access a key value in the .NET assembly. I added this
to the Web.Config of the Web Service however it didnt read the value.
I also tried adding to the Web.config of the Web application however i
am faced with the same problem.

Am I missing any configuration to get this working

Cheers
Prabu


--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 18 '06 #2
Hi Morten
Thanks for your quick response.
The web.config setting is

<add key = "MaximumIterations" value="10" />

and in the code
maximumIteration =
Convert.ToInt32(System.Configuration.Configuration Settings.AppSettings["MaximumIterations"]);
I have got a method to return all the configuration setting. however
this just does not return anything.
private void GetAllAttributes()
{
for( int i = 0;
i<System.Configuration.ConfigurationSettings.AppSe ttings.Count; i++)
{
System.Diagnostics.EventLog.WriteEntry("My
Application",System.Configuration.ConfigurationSet tings.AppSettings[i]);
}
}

Cheers
Prabu Girirajan

Morten Wennevik wrote:
Hi Prabu,

How do you configure web.config?

If you put a key under appSettings you can read it using the
ConfigurationManager.

//web.config
<add key="Mykey" value="MyValue" />

//code
string myKey = ConfigurationManager.AppSettings["MyKey"];

On Mon, 18 Sep 2006 10:55:40 +0200, <pr*************@gmail.comwrote:
Hi,
I have a web application which internally calls certain web methods of
a web service. This web service has a interop to ATL COM Component and
that ATL component calls a .NET assembly.
I would like to access a key value in the .NET assembly. I added this
to the Web.Config of the Web Service however it didnt read the value.
I also tried adding to the Web.config of the Web application however i
am faced with the same problem.

Am I missing any configuration to get this working

Cheers
Prabu

--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 18 '06 #3
Well, your code should work, although in .Net 2.0 you should use
ConfigurationManager instead of ConfigurationSettings. Both should work..

Could you show me your web.config?

- Morten

On Mon, 18 Sep 2006 11:23:49 +0200, <pr*************@gmail.comwrote:
Hi Morten
Thanks for your quick response.
The web.config setting is

<add key = "MaximumIterations" value="10" />

and in the code
maximumIteration =
Convert.ToInt32(System.Configuration.Configuration Settings.AppSettings["MaximumIterations"]);
I have got a method to return all the configuration setting. however
this just does not return anything.
private void GetAllAttributes()
{
for( int i = 0;
i<System.Configuration.ConfigurationSettings.AppSe ttings.Count; i++)
{
System.Diagnostics.EventLog.WriteEntry("My
Application",System.Configuration.ConfigurationSet tings.AppSettings[i]);
}
}

Cheers
Prabu Girirajan

Morten Wennevik wrote:
>Hi Prabu,

How do you configure web.config?

If you put a key under appSettings you can read it using the
ConfigurationManager.

//web.config
<add key="Mykey" value="MyValue" />

//code
string myKey = ConfigurationManager.AppSettings["MyKey"];

On Mon, 18 Sep 2006 10:55:40 +0200, <pr*************@gmail.comwrote:
Hi,
I have a web application which internally calls certain web methodsof
a web service. This web service has a interop to ATL COM Component and
that ATL component calls a .NET assembly.
I would like to access a key value in the .NET assembly. I added this
to the Web.Config of the Web Service however it didnt read the value.
I also tried adding to the Web.config of the Web application however i
am faced with the same problem.

Am I missing any configuration to get this working

Cheers
Prabu

--
Happy Coding!
Morten Wennevik [C# MVP]


--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 18 '06 #4

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

Similar topics

5
by: aualias | last post by:
I am getting the following error: Warning: The dependency 'ShoppingCart, Version=1.0.1895.27037, Culture=neutral' in project 'www.sitename.com' cannot be copied to the run directory because it...
2
by: Torrance S. | last post by:
Hi, I have a class in an assembly that references a value in web.config like this: <appSettings> <add key="mykey" value="myvalue"/> </appSettings> string temp =...
12
by: Mark Broadbent | last post by:
Hi guys, just going through remoting at the moment and a couple of questions relating to .net in general has surfaced. Firstly I have seen in the designer that for the namespace and many of its...
5
by: Matthew Louden | last post by:
I have no idea what this run-time error about. Any ideas? I already change the web.config file for the attribute <customErrors mode="Off"/> but still not work. Server Error in '/'...
1
by: Ivan | last post by:
Hi, I have moved an entire solution from .netframework 1.0 to 1.1; also I have migrated the solution to VS2003. After this I have added a new project (Web) to previous solution; I'm referencing...
6
by: Mikey_Doc | last post by:
Hi We are running cms 2002, Framework 1.0 with Visual studio 2002. We have just upgraded to Framework 1.1 and visual studio 2003. All of our database connection strings are stored within the...
2
by: simon | last post by:
hello, what i'm looking to do is store the path of the app on a the server for reuse in the site. my thoughts so far are... -make a key in the web.config file -retrieve the value in globals.asax...
3
by: Eroc | last post by:
I'm new to XML files so I'm kinda lost here. I found some example code on reading an XML file. My objective is simple. Read the whole XML file into memory. Here is part of my code: Private...
5
by: Alias | last post by:
Hi - I'm trying to implement a custom RoleProvider based on the SqlRoleProvider. I keep receiving a an error that it can't load type 'MyRoleTest.MyRoleProvider' when trying to load my...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.