cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.87k stars 2.92k forks source link

WinForms - Add support for OOP Designer (VS2022) #4019

Open amaitland opened 2 years ago

amaitland commented 2 years ago

The new OOP designer likely requires a new design time class.

Details in https://devblogs.microsoft.com/dotnet/state-of-the-windows-forms-designer-for-net-applications/

https://www.nuget.org/packages/Microsoft.WinForms.Designer.SDK

amaitland commented 2 years ago

Guidance on adding support seems to be limited, have created

amaitland commented 2 years ago

Working branch https://github.com/cefsharp/CefSharp/tree/winforms/oopdesigner

Will wait to hear from the WinForms Team before progressing any further with this.

goophps commented 2 years ago

thank you

amaitland commented 2 years ago

Example of crash in https://github.com/cefsharp/CefSharp/issues/4148#issue-1284865877 when using designer.

Still no meaningful error message provided by the designer crash.

amaitland commented 1 year ago

Thanks to @davidei1955 for providing a link to a newer designer guide that was published a few months ago.

https://devblogs.microsoft.com/dotnet/custom-controls-for-winforms-out-of-process-designer/

There still isn't a newer SDK available and I was previously very reluctant to provide a dependency on a preview package. After extracting the designer Nupkg I can see it only includes ref assemblies so we should be able to use this as a development dependency (no direct reference will be added to the CefSharp nuget packages).

There's some other code that can be converted to P/Invoke that might simplify designer support.

amaitland commented 1 year ago

Anyone wanting to test out the latest changes in relation to the WinForms OOP Designer can use the latest -CI build from https://www.myget.org/F/cefsharp/ (not the -RCI builds, they won't include the changes yet).

You should hopefully be able to add the ChromiumWebBrowser to a form using the designer, it will just say ChromiumWebBrowser if all goes well.

There's still likely issues. I still regularly see crashes with the WinForms OOP Designer with bare WinForms projects (no CefSharp references), so I suspect there are some issues that still need to be worked out.