473,326 Members | 2,588 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,326 software developers and data experts.

Configuration error

Hello,

I am creating a custom configuration section but I keep having the
error:

Unrecognized attribute 'Type'. Note that attribute names are case-
sensitive. (...\web.config line 42)

Line 42 is:

<add Key="AdSense" Type="Client" Access=""/>

This is my Web.Config code:

<section
name="projSettings"
type="MyApp.Configuration.Config"/>
</configSections>
<projSettings>
<Google>
<add Key="AdSense" Type="Client" Access=""/>
<add Key="Analytics" Type="UserAccount" Access=""/>
</Google>
</projSettings>

And I keep having the error on code line 8 in my C# code:

1 public class Config : ConfigurationSection {
2 [ConfigurationProperty("Google")]
3 public GoogleCollection Google {
4 get { return this["Google"] as GoogleCollection; }
5 } // Google
6
7 public static object GetElement(ConfigSectionType type,
string key) {
8 object parent =
ConfigurationManager.GetSection("projSettings");
9 ConfigurationElementCollection child =
(ConfigurationElementCollection)parent.GetType().G etProperty("projSettings").GetValue(parent,
null);
10 foreach (IKeyProvider element in child) {
11 if (element.Key == key) return element;
12 }
13 return null;
14 }
15 }
16
17 public enum ConfigSectionType {
18 Google,
19 Mail
20 }
21
22 public class Google : ConfigurationElement, IKeyProvider {
23 [ConfigurationProperty("Key", IsRequired = true)]
24 public string Access { get; set; }
25 public string Key { get; set; }
26 public string Type { get; set; }
27 } // Google
28
29 public class GoogleCollection : ConfigurationElementCollection {
30 protected override ConfigurationElement CreateNewElement() {
31 return new Google();
32 }
33 protected override object GetElementKey(ConfigurationElement
element) {
34 return (element as Google).Key;
35 } // GetElementKey
36 }
37
38 interface IKeyProvider {
39 string Key { get; set; }
40 } // IKeyProvider

Does anyone knows what I am doing wrong?

I can't find the problem.

Thanks,

Miguel
Oct 23 '08 #1
1 3416
On Oct 23, 2:12*am, shapper <mdmo...@gmail.comwrote:
Hello,

I am creating a custom configuration section but I keep having the
error:

Unrecognized attribute 'Type'. Note that attribute names are case-
sensitive. (...\web.config line 42)

Line 42 is:

<add Key="AdSense" Type="Client" Access=""/>

This is my Web.Config code:

* * <section
* * * name="projSettings"
* * * type="MyApp.Configuration.Config"/>
* </configSections>
* <projSettings>
* * <Google>
* * * <add Key="AdSense" Type="Client" Access=""/>
* * * <add Key="Analytics" Type="UserAccount" Access=""/>
* * </Google>
* </projSettings>

And I keep having the error on code line 8 in my C# code:

1 * * *public class Config : ConfigurationSection {
2 * * * *[ConfigurationProperty("Google")]
3 * * * *public GoogleCollection Google {
4 * * * * *get { return this["Google"] as GoogleCollection; }
5 * * * *} // Google
6
7 * * * *public static object GetElement(ConfigSectionType type,
string key) {
8 * * * * *object parent =
ConfigurationManager.GetSection("projSettings");
9 * * * * *ConfigurationElementCollection child =
(ConfigurationElementCollection)parent.GetType().G etProperty("projSettings").GetValue(parent,
null);
10 * * * * foreach (IKeyProvider element in child) {
11 * * * * * if (element.Key == key) return element;
12 * * * * }
13 * * * * return null;
14 * * * }
15 * * }
16
17 * * public enum ConfigSectionType {
18 * * * Google,
19 * * * Mail
20 * * }
21
22 * * public class Google : ConfigurationElement, IKeyProvider {
23 * * * [ConfigurationProperty("Key", IsRequired = true)]
24 * * * public string Access { get; set; }
25 * * * public string Key { get; set; }
26 * * * public string Type { get; set; }
27 * * } // Google
28
29 * *public class GoogleCollection : ConfigurationElementCollection {
30 * * * protected override ConfigurationElement CreateNewElement(){
31 * * * * return new Google();
32 * * * }
33 * * * protected override object GetElementKey(ConfigurationElement
element) {
34 * * * * return (element as Google).Key;
35 * * * } // GetElementKey
36 * * }
37
38 * * interface IKeyProvider {
39 * * * string Key { get; set; }
40 * * } // IKeyProvider

Does anyone knows what I am doing wrong?

I can't find the problem.

Thanks,

Miguel
Please, anyone?
Oct 24 '08 #2

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

Similar topics

6
by: chokk | last post by:
All, I am getting the following error when I try to run a form page. Can someone tell me what this is about and show me how to fix it. Thnaks. Server Error in '/' Application...
2
by: Chris_24 | last post by:
To all, I am experiencing difficulties with an asp.net web application and its web.config file. No matter what I try I keep getting the following error: Server Error in '/action' Application....
1
by: Ramanfromoz | last post by:
Hi, Developing a new we application. Everything okay on my local WIN XP PROFESSIONAL, IIS 5.0 running locally. The website is running smoothly. Now, the same code I am copying over to a...
3
by: hB | last post by:
Hi. Error = "The configuration system can only be set once. Configuration system is already set" Exception Details: System.InvalidOperationExcepti­on: The configuration system can only...
2
by: Terry Holland | last post by:
I posted a follow up to an earlier post but did not receive response so here it is again (with original post and response) > This could be because you are running the index service over this web...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
1
by: Jess Chadwick | last post by:
I am attempting to use the Enterprise Library (Jan 2006) Cryptography block to encrypt a credit card number in my ASP.NET 2.0 Commerce Server application. Everything is configured correctly, as...
8
by: Alberto | last post by:
Can you tell me how to read and modify a value in the app.config file using this class? Thank you very much
4
by: aSoundMind | last post by:
Hi there, I recieve this error Server Error in '/integrate' Application. -------------------------------------------------------------------------------- Configuration Error Description: An...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.