We have a class library (consumable by third-party apps not under our control, and deployed as a single file dll with embedded references) that previously used the WebBrowser control. That was a very simple, easy-to-use and -deploy control that is now past its prime. But trying to replace it with WebView2 has been quite a struggle. Now we have it working but we can't get the runtimes to be included in the deployed dll. (We would have settled for the WebView control but that has issues running under Admin rights, bizarrely.)
The library is .NET 4.6.2 (for as much backward compatibility in the .NET Framework as possible). We use Fody Weavers to include RestSharp, NLog, etc and have now added Microsoft.Web.WebView2.Core, Microsoft.Web.WebView2.WinForms and Microsoft.Web.WebView2.Wpf.
We also have the Costura directive UseRuntimeReferencePaths='true'
which I believe is required for .NET Framework projects.
But when I run the app test form - which consumes the library - I get a path error:
The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.InternalGetDirectoryName(String path)
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.LoadWebView2LoaderDll()
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateAsync>d__3.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__23.MoveNext()
I've tried a few things to ensure that the runtimes are included such as embedding them as resources, to no avail.
This is a deal breaker for us if we can't get this working; we MUST have everything included in a single file library/dll. So my question is, has anyone managed to do this? (Praying that the answer is, "Sure! Just do this ...").