title: C# VS12 Designer Error on saving a custom derived form in design mode
body: <p>I currently experience problems in VS12 and the built-in designer. I am using a custom control framework which basically extends basic user controls and DevExpress controls. For a while now i have problems saving a form in design mode when i try to change a property or move one of the controls. I tried to translate the error messages as good as possible (I am using a german version of VS).</p>
  
  <pre><code>Visual Studio Designer Error Message:
  Error during code generation for the MyPropertyMap-property. Error: The property accessor for the MyPropertyMap for the settings object has caused an exception: The enumeration has changed. Enumeration could not be executed.
  </code></pre>
  
  <p>I tried to debug the designer exception using another instance of visual studio with CLR debugging enabled:</p>
  
  <pre><code>System-InvalidOperationException
  The enumeration has changed. Enumeration could not be executed.
  Source: CustomForm
  StackTrace: MyNamespace.Controls.CustomForm.get_FormVariables()
  TargetSite: System.Collections.Hashtable get_FormVariables()
  </code></pre>
  
  <p>It looks like the designer tries to access the property on the form allthough i tried to hide it from designer using the following code:</p>
  
  <pre><code>[NonSerialized]
  private Hashtable formVariables = null;
  [EditorBrowsable(EditorBrowsableState.Never)]
  [Browsable(false)]
  public Hashtable FormVariables
  {
      get
      {
  ...
  </code></pre>
  
  <p>I tried to add the NonSerialized field because i thought serialization of the property might cause the problem. The getter basically queries all controls on the panel of the form and adds them to a hashtable because I am doing some timer based stuff with them. But during design time it is not necessary for the designer to access this property. Any suggestions how i really can hide it from the designer and prevent this error?</p>
  
  <p>If i missed to give any other important input please let me know.</p>
  
  <p>EDIT:</p>
  
  <p>I am still trying to find out what causes the problem. One thing i found out is that when i disable the Optimize Code Gerneration setting in visual studio designer settings the error occurs all the time. When i reenable it there error occures once on the first attempt to save the form - and does not on the second attempt - meaning that the form is saved. I am not sure right now if it does all the time - but at least for the couple of times i tried it did.</p>
  
  <p>All the public properties working with enumerations or other collection objects are implemented to return null if in DesignMode now. The exception still occurs as the designer tries to access the getter functions.</p>
  
  <p>Kind regards.</p>