4

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:\Projects\windows-v2\packages\System.Runtime.WindowsRuntime.4.6.0\build\net461....\ref\netstandard2.0\System.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.

Md Isfar Uddin
  • 692
  • 11
  • 19

2 Answers2

3

I found the solution and I am answering my own question. If anyone will face same problem then it will help.

The problem is not in the code. It is a problem in visual studio upgrading problem. Previously the project was in VS 2015 version but when I upgraded the webView, I used VS 2017 version. This is the reason to show the error "ReferencePath" does not define a value for metadata "CopyLocal".

To solve this problem go to the following directory:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin and open Microsoft.Common.CurrentVersion.targets file. Then at Line 3961 change this ...Include="@(ReferencePath)" into ...Include="@(ReferencePath.CopyLocal)"

Md Isfar Uddin
  • 692
  • 11
  • 19
2

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");
    
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398