Reputation:
A contributor made some updates to "Toolkit.win32.ui.controls" in their own branch. I downloaded, compiled, and referenced the resulting dll in my project. I see the API changes in the Object Browser (see attached image); However, the compiler does not seem to see these changes, as I get errors whenever I try to use the additional APIs.
The branch: https://github.com/rjmurillo/UWPCommunityToolkit/tree/WebView/NavigateWithHttpMessage
The changes he made: https://github.com/Microsoft/WindowsCommunityToolkit/pull/2195
Where the error occurs:
Uri url = webView.BuildLocalStreamUri("MyTag", "/Minesweeper/default.html");
The error:
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
It's almost as if it is still using the original, unmodified, version of the reference, because it does recognize "WebView".
The 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>
The project file:
[![<?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]
Upvotes: 0
Views: 280
Reputation: 95
One of the goals of the Windows Community Toolkit version of the WebView is to provide separation between WinRT and .NET concepts and provide an abstraction from the nature and limitations of providing a bridge between Win32 and UWP applications, so some APIs were omitted from the initial release. By exposing BuildLocalStreamUri(String, String)
without any abstraction, the return value provides a relative URI to the Win32WebViewHost UWP application hosting the web view (e.g. ms-local-stream://microsoft.win32webviewhost_cw5n1h2txyewy_54657374/foo.htm
), rather than the Windows Forms or WPF application itself, which can be confusing.
The branch mentioned does provide support for BuildLocalStreamUri
, however, it is intended to be used within the context of NavigateToLocalStreamUri(Uri, IUriToStreamResolver)
or NavigateToLocal(String)
to provide that abstraction. Using either of those methods will invoke BuildLocalStreamUri
internally to normalize the URI, and invoke an instance of IUriToStreamResolver
to translate an asset to a System.IO.Stream
.
Upvotes: 1