473,783 Members | 2,286 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 3485
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
1614
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
2853
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
2390
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
3737
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
6436
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
10222
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
57115
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
12061
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
9643
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
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
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
10147
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
9946
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...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
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...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.