Mono WebBrowser Monitor for Linux
I am writing an application that I would like to run under Windows or Linux. Since this is a text-based application, the obvious choice for rendering and user interaction is to use html in the control WebBrowser
. This all works fine with Mono on Windows, but I absolutely don't understand how to get it to work with Mono on Linux. I am running Linux Mint 17, MonoDevelop and Firefox installed. The following code snippet compiles and runs, but when the application starts, wbMain
it is not displayed. Application dies when trying to render html string with 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);
source to share
this.wbMain = Mono.WebBrowser.Manager.GetNewInstance();
The problem is yours GetNewInstance()
from what I understand here. GetNewInstance
assumes the default Windows platform, you need to pass your own Mono.WebBrowser.Platform
to render it in the right framework (like Gtk).
In the source code I linked, you can see, by default it GetNewInstance()
returns Platform.Winforms
;
public static IWebBrowser GetNewInstance ()
{
return Manager.GetNewInstance (Platform.Winforms);
}
Also Mono.WebBrowser has been removed in favor of WebkitSharp. You really should be using WebkitSharp to do this now. WebkitSharp had ... some problems, so the currently open version is called open-webkit-sharp , which might work for you too. The code on it has been at least updated since 2012. Whereas Mono WebBrowser and webkit-sharp have not had major code changes ... in years, at least 5 to 7 years.
I've also had good luck with the open source version of Awesomium , and it's a staple in the gaming industry. Again, the open source version of Awesomium hasn't had any major updates since 2012. However, you can get a paid version of Awesomium if money / cost is not an issue and the latest updates.
source to share