Status of WinForms in NativeAOT

What we have with WinForms

Today I would like to share my understanding of the status of WinForms and what’s left. I hope that WinForms would be working by that time, but unfortunately this is not yet happens. I would like to brag a lot how WinForms is usable, but unfortunately current form has it’s limitations.

Currently WinForms successfully compiles and runs WinForms which use supported controls. Other controls like DataGridView may or may not works. I simply did not test them. Overall average size of application is 37Mb for me. That’s moderately good in my opinion. Startup time not excellent, which will be improved hopefully, I have no idea how inter-tangled WinForms codebase. If you remember it was done at a time when Microsoft provide holistic solutions for customers which are magically works most of the time. Because of that there cases like PictureBox bring dependency on WebRequest and friends. WebRequest is what we have prior to HttpClient and most codebases right now try not use that class.

Some marshaling not fully implemented, for example VARIANT support and having [MarshalAs(PreserveSig=false) and methods which return non-void type. CoClass support not there and likely would be not implemented which is broke file dialogs, but that’s should be replaced in WinForms repo, so probably not big deal.

What’s needed for NativeAOT support for WinForms? You should provide custom implementation of ComWrappers which will take care of COM marshaling required for WinForms.

// Line what's needed.
// Regular WinForms stuff.
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());

WinFormsComInterop is experimental implementation of ComWrappers from here, which you can add to your project and start playing with NativeAOT. I would suggest not look at that package too close, since I’m embarrased how much duck typing there, but at least you can start playing with tech. Also I promise to publish that as Nuget package, just busy for now, to properly package and publish.

Stop thinking that WinForms not supported in NativeAOT. It is barely supported! Play! Have nerd fun!

Math lover, lost in the woods of software development

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Distributed load testing in JMeter

I would like to discover the goods and approvable things for the best of all.

Learning How to Use OrientDB’s Intuitive Module OrientJS

Introducing CourseKit: headless online course platform

Priority Based CPU Scheduling algorithm in Operating Systems

Odoo Attachments to S3

Use Your Storage Space More Effectively with ZFS: Exploring vdevs

Laravel and Vue: Creating a Portfolio website with a CRUD admin panel — Chapter Four

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrey Kurdyumov

Andrey Kurdyumov

Math lover, lost in the woods of software development

More from Medium

Wpf.Extensions.Hosting for running WPF on Generic Hosts has been released.

Extend your .NET WCF codebase’s life expectancy with CoreWCF

The real history of Dotnetcore.NPOI

How to use builders for complex objects, directly or loosely coupled!