Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows Forms] Controls support #1100

Closed
39 of 41 tasks
kant2002 opened this issue May 9, 2021 · 8 comments
Closed
39 of 41 tasks

[Windows Forms] Controls support #1100

kant2002 opened this issue May 9, 2021 · 8 comments
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation

Comments

@kant2002
Copy link
Contributor

kant2002 commented May 9, 2021

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

Common Controls

  • Button
  • CheckBox
  • CheckedListBox
  • ComboBox
  • DateTimePicker
  • Label
  • LinkLabel
  • ListBox
  • ListView
  • MaskedTextBox
  • MonthCalendar Crash on startup
  • NotifyIcon
  • NumericUpDown
  • PictureBox
  • ProgressBar
  • PropertyGrid
  • RadioButton
  • RichTextBox.
  • TextBox
  • ToolTip
  • TrackBar
  • TreeView
  • WebBrowser Only events are missing I believe.

Containers

  • FlowLayoutPanel
  • GroupBox
  • Panel
  • SplitContainer
  • TabControl
  • TableLayoutPanel

Menu & Toolstrip

  • ContextMenuStrip
  • MenuStrip
  • StatusStrip
  • ToolStrip
  • ToolStripContainer
  • ToolStripSplitButton

Dialogs

  • OpenFileDialog. on .NET 6 only. Nothing can be done for .NET 5 apps
  • SaveFileDialog. on .NET 6 only. Nothing can be done for .NET 5 apps
  • FolderBrowserDialog. Need support for Marshal.FinalReleaseComObject in NativeAOT or removal of this pattern in WinForms repo.
  • FontDialog.
  • ColorDialog.

DataGridView

  • DataGridView.

All crashes so far is from loading images from stream and require support for Interop.Ole32.IStream from System.Drawing.Common

This is resurrection of dotnet/corert#7995 and all tests was done with WinFormsComWrappers from https://github.com/kant2002/WinFormsComInterop/

To make combobox works require implementation of Accessibility.IAccessible.

@jkotas jkotas added the area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation label May 9, 2021
@kant2002
Copy link
Contributor Author

Combobox is working now, but with broken accessibility.

@kant2002
Copy link
Contributor Author

Combobox is working now.

@weltkante
Copy link

weltkante commented May 31, 2021

Most likely exception and hopefully not due to missing IDispatch support.

I'm pretty sure IDispatch is needed for WebBrowser scripting and eventing support (and besides WebBrowser, also for some Clipboard / Drag'n'drop scenarios; also for ActiveX hosting scenarios, both ways, consuming and providing controls). We had several recent issues due to changes in how IDispatch works in WinForms in .NET Core (its no longer provided by base classes, users have to request it explicitly now). So its clearly needed and people are using it.

You may be able to run a limited form of WinForms this way, but definitely cannot get it fully working without proper COM support. It may be possible to roll custom COM support into WinForms (for e.g. IDispatch and whatever else is missing) but its probably still quite some work.

@JensNordenbro
Copy link

The work that is related to this item is for NativeAOT as I understand it; not the AOT (PublishReadyToRun) of NET6 today and related to COM issues.
Today it is not possible to trim a publish of a net6 winforms/wpf setup. This also seems to be dependent upon COM issues.

Will this work improve on NET6 trimming capability in current days AOT or does this only apply to NativeAOT?

@kant2002
Copy link
Contributor Author

This work does not affect trimming in any way. At least I think that's separate issue.

This also seems to be dependent upon COM issues.

If not blocked by tooling, you may have similar experience with PublishReadyToRun and trimming, since trimming right now disable COM support. You have two paths from here, enable com support using BuiltInComInteropSupport, unlikely improve size of your app. Second path, is to add custom ComWrappers instance. Obviously you can write ComWrappers yourself and not rely on my library.

Will this work improve on NET6 trimming capability in current days AOT or does this only apply to NativeAOT?

Any further work on WinForms would require improve trimming of WinForms itself, and would happens in WinForms repo itself. So I would say, any NativeAOT work and ReadyToRun work would go side-by-side and improve both at the same time. At least I see it this way now.

Other option which may help you, is to use custom build of WinForms where you remove all not used code yourself. With WinForms that's extremely simple to do.

WPF is out of discussion for now, due to lack of resources (IMO) in supporting team.

@JensNordenbro
Copy link

JensNordenbro commented Nov 15, 2021

Just to clarify; I assume the gap in webbrowsing component is related to nuget Microsoft.Web.WebView2 ?

@kant2002
Copy link
Contributor Author

No, this is regular System.Windows.Forms.WebControls. It's hard to make that works and not break existing code. Somewhat that control is working, but I see gaps in the supporting features. New WebView2 support is here MicrosoftEdge/WebView2Feedback#1490

@jkotas
Copy link
Member

jkotas commented Mar 3, 2023

WinForms support for Native AOT is tracked by dotnet/winforms#4649

@jkotas jkotas closed this as completed Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation
Projects
None yet
Development

No branches or pull requests

4 participants