wpf webkit html5,c# - WebKitBrowser with WPF - Stack Overflow

I am trying to use the WebKitBrowser with a WPF application, but am getting a runtime error that says:

FileNotFoundException was unhandled by user code:

An exception of type 'System.IO.FileNotFoundException' occurred in WpfApplication1.exe but was not handled in user code

Additional information: Could not load file or assembly 'WebKit.Interop, Version=533.0.0.0, Culture=neutral, PublicKeyToken=b967213f6d29a3be' or one of its dependencies. The system cannot find the file specified.

The exception is occurring where I am creating an instance of the WebKitBrowser (inside the constructor of my MainWindow.xaml.cs file):

System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();

WebKit.WebKitBrowser browser = new WebKit.WebKitBrowser();

browser.Navigate("http://www.google.com");

host.Child = browser;

browser.Show();

grdBrowserHost.Children.Add(host);

I have the required using statements at the top of my .cs file:

using System.Windows.Forms;

using WebKit;

I have surrounded that code with a try-catch statement, but when I then run my code, the WebKitBrowser is not added to the window as I want it to be, so I'm guessing that the exception is being caught/ handled- though I don't see the Console.WriteLine(); message that I added to my try-catch statement.

I have tried catching a FileNotFoundException, or an Exception, but with the same result- the application runs in exactly the same way as it did before I added the code to create an instance of the WebKitBrowser.

grdBrowserHost is the name that I gave to the XML element where I want to display the browser, although I have not written anything inside that XML element- do I need something there to be able to display the browser? That part of my XML is:

Edit

Although I will want to be using the WebKit browser, or another browser that supports JavaScript, etc, I've had a look into using the 'built in' web browser provided by WPF, and have edited my XAML to include the following markup inside the tags where I want to display the browser:

Height="100"

Margin="10, 10, 0, 0"

VerticalAlignment="Top"

Width="100"

Name="BuiltInBrowser" />

In the Design view in Visual Studio 2015, this markup shows a rectangular area on my application window where the browser will be displayed, however, when I run the application, the WebBrowser is not displayed on the main window, even though the Design view in Visual Studio 2015 is showing a rectangular area (grey colouring) where the WebBrowser is located.

Why isn't the WebBrowser being displayed on the application window when I run the application, even though it is being displayed in the Design view?

How can I display a WebKitBrowser here, rather than a WebBrowser?

If I try to open tags in my XAML, that line displays a compile error message that says:

WebKitBrowser is not supported in a Windows Presentation Foundation (WPF) project

How can I include/ reference WebKitBrowser so that it is supported, and I can use it?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值