Thanks @xiaoyao
The demo works well as a simple application with one form but I found two related problems if the code is used with multiple forms.

1. The form using Webview2 can be opened and used once but if closed and reopened the program crashes. A workaround is to hide the form instead of closing it then show again when required.
2. For the same reason it is impossible to have more than one form using Webview2. No workaround for this.