CefSharp icon indicating copy to clipboard operation
CefSharp copied to clipboard

WinForms - Add support for OOP Designer (VS2022)

Open amaitland opened this issue 2 years ago • 6 comments

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 avatar Feb 24 '22 19:02 amaitland

Guidance on adding support seems to be limited, have created

  • https://github.com/dotnet/winforms/discussions/6757
  • https://github.com/dotnet/winforms/discussions/6758

amaitland avatar Feb 25 '22 00:02 amaitland

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

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

amaitland avatar Feb 25 '22 00:02 amaitland

thank you

goophps avatar Feb 25 '22 08:02 goophps

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 avatar Jun 27 '22 00:06 amaitland

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).

  • Commit https://github.com/cefsharp/CefSharp/commit/1dc71ee48645ee8c75f682251eece2c87e105753 adds reference to the new designer SDK.
  • Additional refactoring in https://github.com/cefsharp/CefSharp/commit/1273afcda8f1c4267e0fc0745f350db3d67e43c7 to avoid referencing CefSharp.Core.Runtime.dll. (Change to P/Invoke)

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

amaitland avatar Mar 15 '23 03:03 amaitland

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.

amaitland avatar Mar 15 '23 03:03 amaitland