Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

c# - Upgrading WebBrowser class into WebView class in winforms application

In my winforms application, I used WebBrowser class which is using IE browser. I want to update it into WebView class so that I can use Edge browser. That's why I installed packages Microsoft.Toolkit.Forms.UI.Controls.WebView. Then I changed some existing code which is compatible with WebView. But when I ran the project, I found the below errors after installing that package.

The item "C:Projectswindows-v2packagesSystem.Runtime.WindowsRuntime.4.6.0uild et461.... ef etstandard2.0System.Runtime.WindowsRuntime.dll" in item list "ReferencePath" does not define a value for metadata "CopyLocal". In order to use this metadata, either qualify it by specifying %(ReferencePath.CopyLocal), or ensure that all items in this list define a value for this metadata.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To use a WebViewCompatible control in a Windows Forms application:

  1. Install package Microsoft.Toolkit.Forms.UI.Controls.WebView
  2. Right click on an empty area in Toolbox → select Choose Items → From the Choose Toolbox Items → choose .NET Framework Component tab → Click on Browse → Browse the package folder and choose Microsoft.Toolkit.Forms.UI.Controls.WebView dll → Click Open → Click OK
  3. Drop an instance of WebViewCompatible control on the form.
  4. In the Load event or in constructor after InitializeComponent add code to navigate to the address you want:

    webViewCompatible1.Navigate("https://www.google.com");
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...