C# Using Microsoft.Toolkit.Win32.UI.Controls in .NET Framework 4.6.1 - Web Browser Control Upgrade

馋奶兔 提交于 2019-12-20 02:50:09

问题


My program has been using the Web Browser Control for a while in my program, but it simply does not cut it anymore as it isn't able to work properly with the javascript on most webpages. Luckily, Microsoft has released a new web browser tool for us to use and it uses EdgeHTML powered webview. The nugget package installer here does not work in my program, however. When I run that in the package manager console, I get this error

Install failed. Rolling back... Package 'Microsoft.Toolkit.Win32.UI.Controls.3.0.0' does not exist in project 'Email Analyzer' Package 'Microsoft.Toolkit.Win32.UI.Controls.3.0.0' does not exist in folder 'C:\Users\thood\Desktop\Projects\Email Analyzer\packages' Executing nuget actions took 6.64 sec Install-Package : Could not install package 'Microsoft.Toolkit.Win32.UI.Controls 3.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. At line:1 char:1 + Install-Package Microsoft.Toolkit.Win32.UI.Controls -Version 3.0.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Additionally, here is the dialogue for the install process

PM> Install-Package Microsoft.Toolkit.Win32.UI.Controls -Version 3.0.0 

Attempting to gather dependency information for package 'Microsoft.Toolkit.Win32.UI.Controls.3.0.0' with respect to project 'Email Analyzer', targeting '.NETFramework,Version=v4.6.1'
Gathering dependency information took 1.91 sec
Attempting to resolve dependencies for package 'Microsoft.Toolkit.Win32.UI.Controls.3.0.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.Toolkit.Win32.UI.Controls.3.0.0'
Resolved actions to install package 'Microsoft.Toolkit.Win32.UI.Controls.3.0.0'
Retrieving package 'Microsoft.Toolkit.Win32.UI.Controls 3.0.0' from 'nuget.org'.
GET https://api.nuget.org/v3-flatcontainer/microsoft.toolkit.win32.ui.controls/3.0.0/microsoft.toolkit.win32.ui.controls.3.0.0.nupkg
OK https://api.nuget.org/v3-flatcontainer/microsoft.toolkit.win32.ui.controls/3.0.0/microsoft.toolkit.win32.ui.controls.3.0.0.nupkg 305ms
Installing Microsoft.Toolkit.Win32.UI.Controls 3.0.0.

Is this simply because the toolkit is not supported for 4.6.1? Rolling my program back to 3.0.0 is not really an option because I use references to System.Threading.Tasks which is not available in 3.0.0. Has anyone running 4.6.1 been able to successfully integrate the new toolkit?


回答1:


Ok, here's the deal, there's two steps to solve this issue. Hopefully if anyone else gets this error my answer will be able to save you all some time. I'll break this into 2 easy steps with links.

  1. First you'll want to read this article on how to update your framework. When you get to the "Target Framework:" dropdown, you'll want to select "Install other frameworks..." and find and download and run 4.6.2. Done.

  2. Next, you'll want to see what version of Windows you are running. Follow this: Start > Settings (gear icon towards bottom left) > System > About (bottom of left panel) > Scroll down to "Windows specifications" > Check your version. If you are running 1803, great - you're all done here! If you're like me and not already on version 1803 (I was on 1709) go here and click "Update Now" to download the installer on your PC. Find the installer and run. This will take awhile to finish installing so be patient and plug in your PC if you need to.

That's it. Once this is installed you should be able to use WebViewControl in Visual Studio 4.6.2! Cheers!



来源:https://stackoverflow.com/questions/50611822/c-sharp-using-microsoft-toolkit-win32-ui-controls-in-net-framework-4-6-1-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!