Webview 编译uwp社区工具包dll问题

Webview 编译uwp社区工具包dll问题,webview,windows-community-toolkit,Webview,Windows Community Toolkit,一位贡献者在自己的分支中对“Toolkit.win32.ui.controls”进行了一些更新。我在项目中下载、编译并引用了生成的dll。我在对象浏览器中看到API更改(请参见附图);但是,编译器似乎看不到这些更改,因为每当我尝试使用额外的API时都会出现错误 该处: 他所做的改变是: 发生错误的地方: Uri url = webView.BuildLocalStreamUri("MyTag", "/Minesweeper/default.html"); 错误: Severity C

一位贡献者在自己的分支中对“Toolkit.win32.ui.controls”进行了一些更新。我在项目中下载、编译并引用了生成的dll。我在对象浏览器中看到API更改(请参见附图);但是,编译器似乎看不到这些更改,因为每当我尝试使用额外的API时都会出现错误

该处:

他所做的改变是:

发生错误的地方:

 Uri url = webView.BuildLocalStreamUri("MyTag", "/Minesweeper/default.html");
错误:

Severity    Code    Description Project File    Line    Suppression State
Error   CS1061  'WebView' does not contain a definition for 'BuildLocalStreamUri' and no extension method 'BuildLocalStreamUri' accepting a first argument of type 'WebView' could be found (are you missing a using directive or an assembly reference?)   Test.WPF    C:\Users\Adam\Desktop\Test.WPF\MainWindow.xaml.cs   29  Active
这几乎就像它仍然在使用原始的、未修改的引用版本,因为它确实识别“WebView”

XAML:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SparkStore.WPF"
        xmlns:winforms="clr-namespace:Microsoft.Toolkit.Win32.UI.Controls.WinForms;assembly=Microsoft.Toolkit.Win32.UI.Controls"
        xmlns:WPF="clr-namespace:Microsoft.Toolkit.Win32.UI.Controls.WPF;assembly=Microsoft.Toolkit.Win32.UI.Controls" x:Class="Test.WPF.MainWindow"
        mc:Ignorable="d"
        Title="Test" Height="450" Width="800">
    <Grid>
        <WPF:WebView x:Name="webView" Margin="0"/>
    </Grid>
</Window>

项目文件:

[![<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{525B29B6-0498-46D2-A1E9-EDBBFA4FA34D}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <RootNamespace>Test.WPF</RootNamespace>
    <AssemblyName>Test.WPF</AssemblyName>
    <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <WarningLevel>4</WarningLevel>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <TargetFrameworkProfile />
    <PublishUrl>publish\</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Microsoft.Toolkit.Win32.UI.Controls">
      <HintPath>..\UWPCommunityToolkit\Microsoft.Toolkit.Win32\Microsoft.Toolkit.Win32.UI.Controls\bin\AnyCPU\Release\net462\Microsoft.Toolkit.Win32.UI.Controls.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Design" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xaml">
      <RequiredTargetFramework>4.0</RequiredTargetFramework>
    </Reference>
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
  </ItemGroup>
  <ItemGroup>
    <ApplicationDefinition Include="App.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </ApplicationDefinition>
    <Page Include="MainWindow.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </Page>
    <Compile Include="App.xaml.cs">
      <DependentUpon>App.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="MainWindow.xaml.cs">
      <DependentUpon>MainWindow.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Properties\AssemblyInfo.cs">
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
      <Visible>False</Visible>
      <ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <ItemGroup>
    <Resource Include="Readme.txt" />
  </ItemGroup>
  <Import Project="..\Test\Test.projitems" Label="Shared" />
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>][1]][1]
[[
调试
任意CPU
{525B29B6-0498-46D2-A1E9-EDBBFA4FA34D}
温克斯
Test.WPF

WebView的Windows社区工具包版本的目标之一是在WinRT和.NET概念之间提供分离,并从提供Win32和UWP应用程序之间桥梁的性质和局限性中提供抽象,因此在初始版本中省略了一些API。通过公开
BuildLocalStreamUri(String,String)
在没有任何抽象的情况下,返回值提供承载web视图的Win32WebViewHost UWP应用程序的相对URI(例如
ms local)-stream://microsoft.win32webviewhost_cw5n1h2txyewy_54657374/foo.htm
),而不是Windows窗体或WPF应用程序本身,这可能会令人困惑


所提到的分支确实提供了对
BuildLocalStreamUri
的支持,但是,它打算在
navigateLocalStreamUri(Uri,IUriToStreamResolver)
navigateLocalStreamUri(字符串)的上下文中使用
提供该抽象。使用这两种方法中的任何一种都将在内部调用
BuildLocalStreamUri
来规范URI,并调用
IUriToStreamResolver
的实例来将资产转换为
System.IO.Stream
WebView的Windows社区工具包版本的目标之一是在WinRT和.NET概念之间提供分离,并从提供Win32和UWP应用程序之间桥梁的性质和限制中提供抽象,因此在初始版本中省略了一些API
在没有任何抽象的情况下,返回值为承载web视图的Win32WebViewHost UWP应用程序(例如,
ms local)提供了一个相对URI-stream://microsoft.win32webviewhost_cw5n1h2txyewy_54657374/foo.htm
),而不是Windows窗体或WPF应用程序本身,这可能会令人困惑

所提到的分支确实提供了对
BuildLocalStreamUri
的支持,但是,它打算在
navigateLocalStreamUri(Uri,IUriToStreamResolver)
navigateLocalStreamUri(字符串)的上下文中使用
以提供该抽象。使用这两种方法中的任何一种都将在内部调用
BuildLocalStreamUri
以规范化URI,并调用
IUriToStreamResolver
的实例以将资产转换为
System.IO.Stream