Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

[Windows Forms] Controls support #7995

Open
17 of 32 tasks
kant2002 opened this issue Feb 18, 2020 · 8 comments
Open
17 of 32 tasks

[Windows Forms] Controls support #7995

kant2002 opened this issue Feb 18, 2020 · 8 comments

Comments

@kant2002
Copy link
Contributor

Here the summary of controls working in Windows Forms in my limited testing

Common Controls

  • Button
  • CheckBox
  • CheckedListBox Crash on click when empty or on startup if any items
  • ComboBox Crash on dropdown open
  • DateTimePicker Crash on select date
  • Label
  • LinkLabel Crash on hover
  • ListBox Crash on select item
  • ListView
  • MaskedTextBox
  • MonthCalendar Crash on startup
  • NotifyIcon Crash on startup when icon set
  • NumericUpDown
  • PictureBox Crash on startup
  • ProgressBar
  • RadioButton
  • RichTextBox Crash on startup
  • TextBox
  • ToolTip
  • TreeView
  • WebBrowser Crash on startup

Containers

  • FlowLayoutPanel
  • GroupBox
  • Panel
  • SplitContainer Crash on hover
  • TabControl
  • TableLayoutPanel

Menu & Toolstrip

  • ContextMenuStrip Crash on show
  • MenuStrip Crash on startup
  • StatusStrip Crash on startup when use ToolstripDropDown and ToolStripSplitButton
  • ToolStrip
  • ToolStripContainer

I can understand that some issues i due to lack of COM support, but some "crash on selection" looks more like CoreRT issue. Anyway, this issue to give visibility for list of supported out-of-box controls.

@MichalStrehovsky
Copy link
Member

Great list, thank you for documenting this!

@teobugslayer
Copy link
Contributor

teobugslayer commented Mar 21, 2020

I experimented a bit with the MenuStrip. Unfortunately, I am not a .NET dev, so I hit an impenetrable wall.

On startup, I get a very weird exception (Maybe there's a separate issue with exception generation of CoreRT):

Unhandled exception at 0x00007FF7F1EF5634 in winforms.exe: 0x892BE4EA. occurred

And the following call stack:

FailFast�() Unknown
S_P_CoreLib_System_Runtime_CalliIntrinsics__Call_5�() Unknown
S_P_CoreLib_System_Runtime_CalliIntrinsics__CallVoid_3�() Unknown
S_P_CoreLib_System_Runtime_EH__UnhandledExceptionFailFastViaClasslib�() Unknown
S_P_CoreLib_System_Runtime_EH__DispatchEx�() Unknown
RhThrowEx�() Unknown
RhpThrowEx() Line 191 Unknown
S_P_Interop_Internal_Runtime_CompilerHelpers_RuntimeInteropData__GetStructUnsafeStructSize�() Unknown
S_P_CoreLib_System_Runtime_InteropServices_Marshal__SizeOfHelper�() Unknown
S_P_CoreLib_System_Runtime_InteropServices_Marshal__SizeOf_1�() Unknown
System_Drawing_Common_System_Drawing_Icon__BmpFrame�() Unknown
System_Drawing_Common_System_Drawing_Icon__ToBitmap�() Unknown
System_Windows_Forms_Primitives_System_Windows_Forms_DpiHelper__GetBitmapFromIcon�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripScrollButton__get_UpImage�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripScrollButton__CreateControlInstance�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripScrollButton___ctor�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripDropDownMenu__get_UpScrollButton�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripDropDownMenu__SetDisplayedItems�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStrip__OnLayout�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripDropDown__OnLayout�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripDropDownMenu__OnLayout�() Unknown
System_Windows_Forms_System_Windows_Forms_Control__PerformLayout_1�() Unknown
System_Windows_Forms_System_Windows_Forms_Control__PerformLayout�() Unknown
System_Windows_Forms_System_Windows_Forms_Control__ResumeLayout_0�() Unknown
System_Windows_Forms_System_Windows_Forms_Layout_LayoutTransaction__Dispose�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripItemCollection__AddRange�() Unknown
System_Windows_Forms_System_Windows_Forms_ToolStripItemCollection__AddRange�() Unknown
winforms_winforms_Form1__InitializeComponent() Line 80 Unknown
winforms_winforms_Form1___ctor() Line 17 Unknown
winforms_winforms_Program__Main() Line 17 Unknown

I poked a bit blindly around the source code of WInForms and found this very suspicious code:

Marshal.SizeOf(typeof(SafeNativeMethods.BITMAPINFOHEADER))

I blindly tried some permutations inside rd.xml, similar to the following, but frankly, all this could have been latin incantations from the necronomicon, so I assume I did not do it correctly. I always received the same exception regardles of which assemblies I included in the list.

<Assembly Name="System.Drawing.Common"  Dynamic="Required All" />
      <Assembly Name="System.Drawing.Primitives" Dynamic="Required All" />
      <Assembly Name="System.Windows.Forms" Dynamic="Required All" />
      <Assembly Name="mscorlib" Dynamic="Required All" />

I'm leaving this in hope that someone could make sense of the issue.

@jkotas
Copy link
Member

jkotas commented Mar 21, 2020

Marshal.SizeOf(typeof(SafeNativeMethods.BITMAPINFOHEADER))

You can submit PR to WinForms to change BITMAPINFOHEADER to struct and this line to sizeof(SafeNativeMethods.BITMAPINFOHEADER). It has significantly better performance everywhere, and it is guaranteed to be compatible with CoreRT.

@teobugslayer
Copy link
Contributor

Marshal.SizeOf(typeof(SafeNativeMethods.BITMAPINFOHEADER))

You can submit PR to WinForms to change BITMAPINFOHEADER to struct and this line to sizeof(SafeNativeMethods.BITMAPINFOHEADER). It has significantly better performance everywhere, and it is guaranteed to be compatible with CoreRT.

Even if I do it, how can I verify that this fixes the CoreRT issue? Or, more to the point, if I have built the System.WIndows.Forms and friends assemblies on my machine, how can I reference them from my test CoreRT project?

@Suchiman
Copy link
Contributor

I'd imagine the instructions in https://github.com/dotnet/winforms/blob/master/Documentation/debugging.md should work

@teobugslayer
Copy link
Contributor

I'd imagine the instructions in https://github.com/dotnet/winforms/blob/master/Documentation/debugging.md should work

I suspect the rabbit hole is quite deep :D Challenge accepted! And thank you for the hint!

MichalStrehovsky added a commit to MichalStrehovsky/corert that referenced this issue Mar 23, 2020
Plus test coverage.

Fixes the issue reported in dotnet#7995.
@MichalStrehovsky
Copy link
Member

Marshal.SizeOf(typeof(SafeNativeMethods.BITMAPINFOHEADER))

The fact that the compiler doesn't figure this one out is actually a dumb regression I caused when I was moving things around. Fixing this to use sizeof of a struct is still a very good fix (because it's really just so much faster to use sizeof), but I'm also submitting #8053 that should resolve this too.

@jkotas
Copy link
Member

jkotas commented Mar 23, 2020

Also, I have submitted the System.Drawing interop improvement as dotnet/runtime#33967

jkotas pushed a commit that referenced this issue Mar 23, 2020
Plus test coverage.

Fixes the issue reported in #7995.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants