Adding an ImageList control breaks... everything

Issue #130 resolved
Cory Adey created an issue

VS Code Version: 1.35.1

PowerShell Pro Tools Version: 4.7.1

Name Value

PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Steps to recreate:

  • Create a new project
  • Open PowerShell Pro Tools Windows Form Designer
  • Add an ImageList control
  • add any other control (I tried Button and CheckBox)

The following is output to a message box

Piped error: Failed to create component 'Button'. The error message follows:

'System.InvalidCastException: Unable to cast object of type 'System.Windows.Forms.ImageList' to type 'System.Windows.Forms.Control'.

at System.Linq.Enumerable.<CastIterator>d__97`1.MoveNext()

at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)

at IM.WinForms.DesignerHost.ContainsName(String name)

at IM.WinForms.DesignerHost.Add(IComponent component, String name)

at IM.WinForms.DesignerHost.CreateComponent(Type componentClass, String name)

at IM.WinForms.DesignerHost.CreateComponent(Type componentClass)

at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost host)

at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost host, IDictionary defaultValues)

at System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost host, IDictionary defaultValues)

at System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem tool, Control parent, Int32 x, Int32 y, Int32 width, Int32 height, Boolean hasLocation, Bo...'

System.InvalidCastException: Unable to cast object of type 'System.Windows.Forms.ImageList' to type 'System.Windows.Forms.Control'.

at System.Linq.Enumerable.<CastIterator>d__97`1.MoveNext()

at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)

at IM.WinForms.DesignerHost.ContainsName(String name)

at IM.WinForms.DesignerHost.Add(IComponent component, String name)

at IM.WinForms.DesignerHost.CreateComponent(Type componentClass, String name)

at IM.WinForms.DesignerHost.CreateComponent(Type componentClass)

at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost host)

at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost host, IDictionary defaultValues)

at System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost host, IDictionary defaultValues)

at System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem tool, Control parent, Int32 x, Int32 y, Int32 width, Int32 height, Boolean hasLocation, Boolean hasSize, ToolboxSnapDragDropEventArgs e)

OK

That would be bad enough, but if you already have existing controls and go ahead and define properties for the ImageList anyway and use it as the source for Icons etc, it all appears to work in the form designer but if you save it does not create the project.resources.psd1 file and if you then close and open again the form designer it deletes most (for me, all but one) of the controls on the form.

Granted, this was my first go at using PowerShell Pro Tools, maybe I don’t know what I’m doing. I’v just started the trial and this was a pretty simple form with just four buttons, each with an icon; I did manage to break it pretty good though.

Comments (1)

  1. Log in to comment