Jon*_*Jon 3 c# linux mono webbrowser-control
我正在编写一个我希望在Windows或Linux下运行的应用程序.由于它是一个文本应用程序,渲染和用户交互的明显选择是在WebBrowser控件中使用html .这一切在Windows中使用Mono都非常有用,但我绝对不知道如何在Linux中使用Mono让它工作.我正在运行Linux Mint 17,安装了MonoDevelop和Firefox.以下代码片段编译并运行,但是当应用程序启动时,wbMain不会显示.尝试使用时渲染html字符串时应用程序死亡wbMain.
private System.Windows.Forms.Panel pnlMain;
private Mono.WebBrowser.IWebBrowser wbMain;
private System.Windows.Forms.Button btnGo;
this.pnlMain = new System.Windows.Forms.Panel();
this.wbMain = Mono.WebBrowser.Manager.GetNewInstance();
this.wbMain.Activate();
this.btnGo = new System.Windows.Forms.Button();
this.pnlMain.SuspendLayout();
this.SuspendLayout();
//
// pnlMain
//
this.pnlMain.Controls.Add((System.Windows.Forms.Control)this.wbMain.Window);
this.pnlMain.Controls.Add(this.btnGo);
this.pnlMain.Location = new System.Drawing.Point(12, 1);
this.pnlMain.Name = "pnlMain";
this.pnlMain.Size = new System.Drawing.Size(260, 248);
this.pnlMain.TabIndex = 0;
//
// wbMain
//
this.wbMain.Resize(260, 216);
Run Code Online (Sandbox Code Playgroud)
this.wbMain = Mono.WebBrowser.Manager.GetNewInstance();
Run Code Online (Sandbox Code Playgroud)
问题在于你GetNewInstance()从我在这里理解的东西.GetNewInstance默认情况下,假设Windows平台,您需要传递自己Mono.WebBrowser.Platform的内容,以便在您想要的框架中呈现(如Gtk).
你可以在我链接的源代码中看到,默认GetNewInstance()返回Platform.Winforms;
public static IWebBrowser GetNewInstance ()
{
return Manager.GetNewInstance (Platform.Winforms);
}
Run Code Online (Sandbox Code Playgroud)
此外,Mono.WebBrowser已经退役,转而支持WebkitSharp.您现在应该使用WebkitSharp来执行此操作.WebkitSharp有......一些问题,因此目前有一个名为open-webkit-sharp的开放版本也可能适合你.截至2012年,该代码至少是最新的.而Mono WebBrowser和webkit-sharp没有任何重大的代码更改......在几年内,至少5到7年.
我对Awesomium的开放版本也有好运,它是游戏行业的主要产品.同样,Awesomium的开放版本自2012年以来没有任何重大更新.但是,如果金钱/费用不是问题并且最近有更新,您可以获得Awesomium的付费版本.
| 归档时间: |
|
| 查看次数: |
5979 次 |
| 最近记录: |