473,946 Members | 13,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="projSetti ngs"
type="MyApp.Con figuration.Conf ig"/>
</configSections>
<projSettings >
<Google>
<add Key="AdSense" Type="Client" Access=""/>
<add Key="Analytics" Type="UserAccou nt" Access=""/>
</Google>
</projSettings>

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

1 public class Config : ConfigurationSe ction {
2 [ConfigurationPr operty("Google" )]
3 public GoogleCollectio n Google {
4 get { return this["Google"] as GoogleCollectio n; }
5 } // Google
6
7 public static object GetElement(Conf igSectionType type,
string key) {
8 object parent =
ConfigurationMa nager.GetSectio n("projSettings ");
9 ConfigurationEl ementCollection child =
(ConfigurationE lementCollectio n)parent.GetTyp e().GetProperty ("projSettings" ).GetValue(pare nt,
null);
10 foreach (IKeyProvider element in child) {
11 if (element.Key == key) return element;
12 }
13 return null;
14 }
15 }
16
17 public enum ConfigSectionTy pe {
18 Google,
19 Mail
20 }
21
22 public class Google : ConfigurationEl ement, IKeyProvider {
23 [ConfigurationPr operty("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 GoogleCollectio n : ConfigurationEl ementCollection {
30 protected override ConfigurationEl ement CreateNewElemen t() {
31 return new Google();
32 }
33 protected override object GetElementKey(C onfigurationEle ment
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 3506
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="projSetti ngs"
* * * type="MyApp.Con figuration.Conf ig"/>
* </configSections>
* <projSettings >
* * <Google>
* * * <add Key="AdSense" Type="Client" Access=""/>
* * * <add Key="Analytics" Type="UserAccou nt" Access=""/>
* * </Google>
* </projSettings>

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

1 * * *public class Config : ConfigurationSe ction {
2 * * * *[ConfigurationPr operty("Google" )]
3 * * * *public GoogleCollectio n Google {
4 * * * * *get { return this["Google"] as GoogleCollectio n; }
5 * * * *} // Google
6
7 * * * *public static object GetElement(Conf igSectionType type,
string key) {
8 * * * * *object parent =
ConfigurationMa nager.GetSectio n("projSettings ");
9 * * * * *ConfigurationE lementCollectio n child =
(ConfigurationE lementCollectio n)parent.GetTyp e().GetProperty ("projSettings" ).GetValue(pare nt,
null);
10 * * * * foreach (IKeyProvider element in child) {
11 * * * * * if (element.Key == key) return element;
12 * * * * }
13 * * * * return null;
14 * * * }
15 * * }
16
17 * * public enum ConfigSectionTy pe {
18 * * * Google,
19 * * * Mail
20 * * }
21
22 * * public class Google : ConfigurationEl ement, IKeyProvider {
23 * * * [ConfigurationPr operty("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 GoogleCollectio n : ConfigurationEl ementCollection {
30 * * * protected override ConfigurationEl ement CreateNewElemen t(){
31 * * * * return new Google();
32 * * * }
33 * * * protected override object GetElementKey(C onfigurationEle ment
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
391
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 -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and...
2
1620
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. -------------------------------------------------------------------------------- Runtime Error Description: An application error occurred on the server. The current custom
1
2866
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 WINDOWS 2003 SERVER, I created a new website, allocated port number 6000. Created a release version on my local machine and copied the WEB project from my local to http://ACTYD003:6000
3
2398
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 be set once. Configuration system is already set
2
390
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 > application. try to stop indexing this application (from IIS management > console, clear "Index this resource") or stop the index service to test if > you still get error or not. I removed this option but still get the error. The error...
10
3775
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 Error in '/QuickStartv20' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file
1
6447
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 evidenced by the fact that it is running on a production box using the same web.config (but not the same parent web.config). When I call the EncryptSymmetric() method, I get this error: Server Error in '/Store' Application....
8
10231
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
57192
by: aSoundMind | last post by:
Hi there, I recieve this error Server Error in '/integrate' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
3
12074
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 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (machine.config) ---> System.Security.SecurityException: Request for the permission of type
0
10150
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...
0
11552
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11141
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10679
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
9873
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...
0
6097
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4524
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3525
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.