Custom Configuration. Help me, please, to spot the problem. Thank You.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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().GetProperty("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
.



Relevant Pages

  • Re: Tools For Development
    ... hand-held PC's with Windows CE .Net V4.20. ... Please advise what tools I will need to develop a custom database driven app ... For more info, use google ...
    (microsoft.public.windowsce.app.development)
  • Non-VBA way of making custom menus.
    ... Sorry for the new thread but even on Google, ... The webpage I quoted in my ... here is the non-VBA way to create a custom menu: ...
    (microsoft.public.excel.misc)
  • Re: CALL FOR COMPOSITIONS
    ... custom here to leave in the tag that tells you who-said-what when you're ... Google as my newsreader, and even though Zeborah posts the directions for it ... then Zeborah's polite mini-FAQ generally gets accompanied by a number ...
    (rec.arts.sf.composition)
  • Re: any way to do a redirect?
    ... I do have a custom 404 page. ... map on it altho that might be excessive. ... >> Google partially indexed the site. ... >> but google addresses for pages inside these folders are all wrong and ...
    (microsoft.public.frontpage.client)
  • Re: Question on ConfigurationElementCollection design
    ... a question was posted on ConfigurationElementCollection design as follows: ... "I have 2 questions on using element collections when building a custom ... My code works and the XML in app.config for my custom section looks like this: ... In some cases it might also be nicer to skip the outermost "Stores" ...
    (microsoft.public.dotnet.framework)