How to Embed WebView2 Runtimes in .NET Framework Class Library With Fody Weavers #3970
Replies: 3 comments
-
Hi, @protegesolutions, thanks for your feedback!
Could you help to check if |runtime DLL| all exist? And about: This may be helpful: https://github.com/yunate/Temp |
Beta Was this translation helpful? Give feedback.
-
Hi @yunate. Thanks for your reply. Please also refer to #2645 where I've added a bit more about our situation. In the original question here, I'm pretty sure, tho not 100% certain, that it is the WebView2Loader.dll references which are not being "found". (I referred to "runtimes" because the files are located in a folder called runtimes, emitted by the compiler.) As I mention in the question, we were hoping to replace WebBrowser with WebView2 but the deployment (and other*) complications of the latter are making me nervous about fragility, portability, etc. * We spent a couple of days receiving InvalidCastExceptions which we eventually tracked down to problems with the .csprog files, but that's another story. We just want something simple and bulletproof to handle a pop-up oAuth2 form within the library but I'm beginning to think that we simply have to move that functionality out of the library, which I can see could make more design sense, though it makes things more complicated for the consumer of the library. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've read the two or three (closed) posts that mention the need to do this but they don't seem to resolve the issue.
We have a class library (consumed by third-party apps not under our control, and obviously a single file 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 employ WebView2 has been quite a struggle. Now we have it working but we can't get the runtimes to be included in the 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:
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 library/dll. So my question is, has anyone managed to do this? (Praying that the answer is, "Sure! Just do this ...".
Beta Was this translation helpful? Give feedback.
All reactions