我们已经安装了 Microsoft Edge WebView2 运行时(x86) 以供 WebView2 使用。请参考下面的截图。
我们正在使用.NET Core 3.1框架和WPF进行应用程序开发。
我们的webview2在Visual Studio的调试/发布/发布模式下运行良好,但是一旦安装我们的应用程序,它就无法加载。
当我们以普通权限运行应用程序时,它不会报任何错误,也不会被加载。 当我们以“管理员身份运行”它时,它会给出以下错误: 我们正在使用Visual Studio中的Windows Installer Project扩展来创建.MSI。
我们的XAML代码如下:
UrlToGo是来自我们的ViewModel的。请帮助我们解决。
当我们以普通权限运行应用程序时,它不会报任何错误,也不会被加载。 当我们以“管理员身份运行”它时,它会给出以下错误: 我们正在使用Visual Studio中的Windows Installer Project扩展来创建.MSI。
我们的XAML代码如下:
<UserControl x:Class="SampleApp.Views.SampleWebView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="1" Margin="5" CornerRadius="10" BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="40" ShadowDepth="2" Softness="1" Opacity="0.3" />
</Border.BitmapEffect>
<wv2:WebView2 x:Name="MyWebView" Source="{Binding UrlToGo}" Margin="5 2"/>
</Border>
</Grid>
UrlToGo是来自我们的ViewModel的。请帮助我们解决。
protected override async void OnContentRendered(EventArgs e)
- Poul Bak