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 1 3423
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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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....
|
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...
|
by: hB |
last post by:
Hi.
Error = "The configuration system can only be set once. Configuration
system is already set"
Exception Details: System.InvalidOperationException: The
configuration
system can only...
|
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...
|
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...
|
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...
|
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
|
by: aSoundMind |
last post by:
Hi there, I recieve this error
Server Error in '/integrate' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |