title: "Parameter is not valid" Exception from get_FrameDimensionsList() on form construction
body: <p>I have an application with a Windows Form which sometimes throws a "Parameter is not valid" exception in the wild.  The exception is raised at construction time while traversing auto-generated code (generated by Visual Studio).</p>
  
  <p>Here are some relevant code snips.</p>
  
  <pre><code>// MainForm.cs
  public partial class MyForm : Form
  {
    public MyForm(Action shutdown_request_callback = null)
    {
      Visible = false;
      ShowInTaskbar = false;
      Opacity = 0;
  
      InitializeComponent();
      ...
    }
  }
  
  // MainForm.designer.cs, this is auto-generated
  partial class MainForm
  {
    private void InitializeComponent()
    {
      ...
      this.StatusPane = new StatusPaneUserControl();
      ...
    }
  }
  
  // StatusPaneUserControl.cs
  public partial class StatusPaneUserControl : UserControl
  {
    public StatusPaneUserControl()
    {
      InitializeComponent();
    }
  }
  
  // StatusPaneUserConrol.designer.cs, auto generated code
  partial class StatusPaneUserControl
  {
    private void InitializeComponent()
    {
      this.FolderImage = new System.Windows.Forms.PictureBox();
      ...
      // 
      // FolderImage
      // 
      this.FolderImage.Image = ((System.Drawing.Image)(resources.GetObject("FolderImage.Image")));
      this.FolderImage.InitialImage = ((System.Drawing.Image)(resources.GetObject("FolderImage.InitialImage")));
      this.FolderImage.Location = new System.Drawing.Point(161, 45);
      this.FolderImage.Name = "FolderImage";
      this.FolderImage.Size = new System.Drawing.Size(251, 219);
      this.FolderImage.TabIndex = 8;
      this.FolderImage.TabStop = false;
      this.FolderImage.WaitOnLoad = true;
      ...
      this.Controls.Add(this.FolderImage);
    }
  }
  </code></pre>
  
  <p>The "Parameter is not valid" exception is raised indirectly from <code>Controls.Add</code>.  The actual stack is below.</p>
  
  <pre><code>ArgumentException: Parameter is not valid.
     at System.Drawing.Image.get_FrameDimensionsList()
     at System.Drawing.ImageAnimator.CanAnimate(Image image)
     at System.Drawing.ImageAnimator.ImageInfo..ctor(Image image)
     at System.Drawing.ImageAnimator.Animate(Image image, EventHandler onFrameChangedHandler)
     at System.Windows.Forms.PictureBox.Animate(Boolean animate)
     at System.Windows.Forms.Control.AssignParent(Control value)
     at System.Windows.Forms.Control.ControlCollection.Add(Control value)
     at MyNamespace.StatusPaneUserControl.InitializeComponent()
     at MyNamespace.MainForm.InitializeComponent()
     at MyNamespace.MainForm..ctor(Action shutdown_request_callback)
  </code></pre>
  
  <p>The exception seems to come from <code>get_FrameDimensionsList()</code> which doesn't seem to take any parameters which is confusing since the exception seems to say that some param is bad.  </p>
  
  <p>I found a similar question <a href="https://stackoverflow.com/questions/4622985/c-exception-parameter-is-not-valid-form-dispose-method#">here</a> but is related to dispose which doesn't look applicable here (but would make sense).</p>