473,396 Members | 1,877 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,396 software developers and data experts.

Custom Configuration. Help me, please, to spot the problem. ThankYou.

Hello,

On a custom Web.Config section I keep having the same error. This is
driving me crazy!!!

I keep having the following error:
Unrecognized attribute 'Type'. Note that attribute names are case-
sensitive. (C:\Documents and Settings\Miguel\My Documents\Website
\web.config line 42)

On code line:
object parent = ConfigurationManager.GetSection("projSettings");

And Web.Config line 42 is:
<add Key="AdSense" Type="Client" Access="one"/>

This is my test code to read an item of Google group in my Custom
Section:

bool found;
object parent =
ConfigurationManager.GetSection("projSettings");
ConfigurationElementCollection child =
(ConfigurationElementCollection)parent.GetType().G etProperty("projSettings").GetValue(parent,
null);
foreach (IKeyProvider element in child) {
if (element.Key == "AdSense") found = true;
}

This is my Web.Config:
...
<section
name="projSettings"
type="MyApp.Configuration.ProjSettingsSection"/>
</configSections>

<projSettings>
<Google>
<add Key="AdSense" Type="Client" Access="one"/>
<add Key="Analytics" Type="UserAccount" Access="two"/>
</Google>
</projSettings>

This is my custom configuration section class:

public class ProjSettingsSection : ConfigurationSection {
[ConfigurationProperty("Google")]
public GoogleCollection Google {
get { return this["Google"] as GoogleCollection; }
}
}
public class GoogleCollection : ConfigurationElementCollection {
protected override ConfigurationElement CreateNewElement() {
return new Google();
}
protected override object GetElementKey(ConfigurationElement
element) {
return (element as Google).Key;
}
}
public class Google : ConfigurationElement, IKeyProvider {
[ConfigurationProperty("Key", IsRequired = true)]
public string Key { get; set; }
public string Type { get; set; }
public string Access { get; set; }
}
interface IKeyProvider {
string Key { get; set; }
}

I really tried everything I could think of for the past 2 weeks or
so ...
.... Every time I get free time I go back to this.

I get always the same error.

Could someone, please, help me out?

Thanks,
Miguel
Nov 6 '08 #1
2 3764
"shapper" <md*****@gmail.comwrote in message
news:d9**********************************@b2g2000p rf.googlegroups.com...
Hello,

On a custom Web.Config section I keep having the same error. This is
driving me crazy!!!

I keep having the following error:
Unrecognized attribute 'Type'. Note that attribute names are case-
sensitive. (C:\Documents and Settings\Miguel\My Documents\Website
\web.config line 42)

On code line:
object parent = ConfigurationManager.GetSection("projSettings");

And Web.Config line 42 is:
<add Key="AdSense" Type="Client" Access="one"/>
....
This is my Web.Config:
....
<projSettings>
<Google>
<add Key="AdSense" Type="Client" Access="one"/>
<add Key="Analytics" Type="UserAccount" Access="two"/>
</Google>
</projSettings>
....
public class Google : ConfigurationElement, IKeyProvider {
[ConfigurationProperty("Key", IsRequired = true)]
public string Key { get; set; }
public string Type { get; set; }
public string Access { get; set; }
}
What happens if you use a ConfigurationProperty attribute on Type and
Access?

--
John Saunders | MVP - Connected System Developer

Nov 7 '08 #2
On Nov 7, 1:55*am, "John Saunders" <n...@dont.do.that.comwrote:
"shapper" <mdmo...@gmail.comwrote in message

news:d9**********************************@b2g2000p rf.googlegroups.com...
Hello,
On a custom Web.Config section I keep having the same error. This is
driving me crazy!!!
I keep having the following error:
Unrecognized attribute 'Type'. Note that attribute names are case-
sensitive. (C:\Documents and Settings\Miguel\My Documents\Website
\web.config line 42)
On code line:
object parent = ConfigurationManager.GetSection("projSettings");
And Web.Config line 42 is:
*<add Key="AdSense" Type="Client" Access="one"/>

...
This is my Web.Config:
...
*<projSettings>
* *<Google>
* * *<add Key="AdSense" Type="Client" Access="one"/>
* * *<add Key="Analytics" Type="UserAccount" Access="two"/>
* *</Google>
*</projSettings>

...
*public class Google : ConfigurationElement, IKeyProvider {
* *[ConfigurationProperty("Key", IsRequired = true)]
* *public string Key { get; set; }
* *public string Type { get; set; }
* *public string Access { get; set; }
*}

What happens if you use a ConfigurationProperty attribute on Type and
Access?

--
John Saunders | MVP - Connected System Developer
Yes, I found the problem and it is exactly that!

Thanks,
Miguel
Nov 7 '08 #3

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

Similar topics

11
by: Sagaert Johan | last post by:
I have made a custom control that draws a rectangle when the mouse is down, and does nothing when the mouse is up. I set/reset a flag in MouseDown/Mouse up and use this to do the drawing in the...
2
by: arby | last post by:
Hi There. I have a SortedList collection that I add objects of a custom class to. Rather then explain my app, my question is pretty general so.... Using a simple clsDog: ...
3
by: Damian | last post by:
Hi everyone I'm having an issue with one of our applications. I'm getting the following error when attempting to log in to the site: Server Error in 'xxxxxxxxxxxxxxxx' Application....
6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
6
by: dee | last post by:
Hi In web.config I have to the following: <configuration> <system.web> <customErrors defaultRedirect="error.htm" mode="On" /> </system.web> </configuration>
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
5
by: Graham | last post by:
I have created a custom MembershipProvider called "LassieMembershipProvider" that derives from "MembershipProvider". This providor is located in a Businesslogic layer dll called...
6
by: Jeff Hegedus | last post by:
I have a dll that requires some configuration data. I put the configuration data in a custom configuration section in a config file that is loaded in the installation folder of the dll. If I...
7
by: =?Utf-8?B?RG91Z2llIEJyb3du?= | last post by:
Hi I've written custom configuration section (inherits from System.Configuration.ConfigurationSection) to simplify the contents of the config file and to make life easier when accessing them in...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
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.