title: Getting error when trying to generate xsd:schema using xsd.exe
body: <p>I have a custom configuration section and i want to generate an xsd scheme using the xsd tool, however i get the following error : </p>
  
  <pre><code>Microsoft (R) Xml Schemas/DataTypes support utility
  [Microsoft (R) .NET Framework, Version 4.0.30319.1]
  Copyright (C) Microsoft Corporation. All rights reserved.
  Error: There was an error processing 'C:\Development\XXX Application Framewo
  rk\XXX.AppFramework\bin\Debug\XXX.AppFramework.dll'.
  - There was an error reflecting type 'XXX.AppFramework.Configuration.AppFr
  ameworkEnvironmentConfiguration'.
  - You must implement a default accessor on System.Configuration.ConfigurationL
  ockCollection because it inherits from ICollection.
  </code></pre>
  
  <p>However i do not implement ICollection on my section, it looks like this :</p>
  
  <pre><code>public class AppFrameworkEnvironmentConfiguration : ConfigurationElement
  {
      [ConfigurationProperty("Name")]
      public string Name
      {
          get { return (string)this["Name"]; }
          set { this["Name"] = value; }
      }
  
      [ConfigurationProperty("Description")]
      public string Description
      {
          get { return (string)this["Description"]; }
          set { this["Description"] = value; }
      }
  
      [ConfigurationProperty("ApplicationName")]
      public string ApplicationName
      {
          get { return (string)this["ApplicationName"]; }
          set { this["ApplicationName"] = value; }
      }
  
      [ConfigurationProperty("DeploymentMode",DefaultValue=DeploymentMode.Local)]
      public DeploymentMode DeploymentMode
      {
          get { return (DeploymentMode)this["DeploymentMode"]; }
          set { this["DeploymentMode"] = value; }
      }
  
  
  }
  </code></pre>
  
  <p>It doesnt look like ConfigurationElement implements ICollection so im not sure why i am getting this error ?</p>
  
  <p>Having had a deep look through reflector to find when this error is thrown, im even more perplexed, first off my little test does indeed evaluate to false :</p>
  
  <pre><code>bool test = typeof(ICollection).IsAssignableFrom(typeof    (XXX.AppFramework.Configuration.AppFrameworkEnvironmentConfiguration));
  </code></pre>
  
  <p>In reflector the only place i can find it raise that exception is wrapped in this exact test, i have found it in System.Xml.Reflection.TypeScope.ImportTypeDesc and looks like this :</p>
  
  <pre><code>else if (typeof(ICollection).IsAssignableFrom(type))
  {
      root = TypeKind.Collection;
      elementType = GetCollectionElementType(type, (memberInfo == null) ? null : (memberInfo.DeclaringType.FullName + "." + memberInfo.Name));
      none |= GetConstructorFlags(type, ref exception);
  }
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>private static Type GetCollectionElementType(Type type, string memberInfo)
  {
  return GetDefaultIndexer(type, memberInfo).PropertyType;
  }
  </code></pre>
  
  <p>which calls</p>
  
  <pre><code>internal static PropertyInfo GetDefaultIndexer(Type type, string memberInfo)
  {
  if (typeof(IDictionary).IsAssignableFrom(type))
  {
      if (memberInfo == null)
      {
          throw new NotSupportedException(Res.GetString("XmlUnsupportedIDictionary",     new     object[] { type.FullName }));
      }
      throw new NotSupportedException(Res.GetString("XmlUnsupportedIDictionaryDetails", new object[] { memberInfo, type.FullName }));
  }
  MemberInfo[] defaultMembers = type.GetDefaultMembers();
  PropertyInfo info = null;
  if ((defaultMembers != null) &amp;&amp; (defaultMembers.Length &gt; 0))
  {
      for (Type type2 = type; type2 != null; type2 = type2.BaseType)
      {
          for (int i = 0; i &lt; defaultMembers.Length; i++)
          {
              if (defaultMembers[i] is PropertyInfo)
              {
                  PropertyInfo info2 = (PropertyInfo) defaultMembers[i];
                  if ((info2.DeclaringType == type2) &amp;&amp; info2.CanRead)
                  {
                      ParameterInfo[] parameters = info2.GetGetMethod().GetParameters();
                      if ((parameters.Length == 1) &amp;&amp; (parameters[0].ParameterType == typeof(int)))
                      {
                          info = info2;
                          break;
                      }
                  }
              }
          }
          if (info != null)
          {
              break;
          }
      }
  }
  if (info == null)
  {
      throw new InvalidOperationException(Res.GetString("XmlNoDefaultAccessors", new object[] { type.FullName })); **&lt; HERE IS THE ERROR**
  }
  if (type.GetMethod("Add", new Type[] { info.PropertyType }) == null)
  {
      throw new InvalidOperationException(Res.GetString("XmlNoAddMethod", new object[] { type.FullName, info.PropertyType, "ICollection" }));
  }
  return info;
  }
  </code></pre>
  
  <p>I also tried adding a default parameterless constructor, no different ;-(
  Any ideas ?</p>