ConfigurationElementCollection Gotcha

Here’s a fun way to waste 2 hours of your life. I was writing a custom config section, and trying to figure out why this wasn’t throwing a duplicate key error:

<monitors>
  <monitor name="File" />
  <monitor name="File" />
</monitors>

After surfing Google endlessly, I finally found this on MSDN:

Note that elements with identical keys and values are not considered duplicates, and are accepted silently. Only elements with identical keys but different values are considered duplicates.

That was fun. :-/

No Comments (Add)

There are no comments yet!