2016-07-23 88 views
0

我已經給出了將Gecko瀏覽器組件集成到現有winform控件的任務,但是im面臨的問題是如何配置dll,我嘗試使用不同的版本作爲好了,但沒有運氣,在點它不會加載的dll,並給出了錯誤如何使用Vb.NET Forms配置「Gecko」應用

Unable to find an entry point named 'NS_Alloc' in DLL 'xul'.

我從給定鏈路單獨下載。 Xulrunner 最新的,也是29,但它說,

An error occurred creating the form. See Exception.InnerException for details. The error is: Unable to load DLL 'xul': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Imports System.IO 

進口的System.Xml 進口壁虎 進口的Microsoft.Win32

公共類Form1中

Public Sub New() 
    InitializeComponent() 
    'D:\xulrunner\bin 
    Xpcom.Initialize("D:\\xulrunner\\") 'xulrunner 
    'Xpcom.Initialize("C:\Program Files (x86)\Mozilla Firefox\") 
End Sub 

結束類別

請幫助我,如果任何人已經完成了。

回答

1

最後,我成功地做到這一點,

在寫作的時候,我選擇GeckoFX-33.0XULRunner 33.1.最新版本,

  • 拆開GeckoFX-330.zip,你會得到以下文件: enter image description here
  • GeckoFx文件 enter image description here

  • 引用添加到上面顯示的dll文件,單擊瀏覽並選擇 的Geckofx-Core.dll和Geckofx-Winforms.dll enter image description here enter image description here

  • 在工具箱中,右鍵單擊,然後選擇「選擇項」,選擇 Geckofx-Winforms.dll和壁虎WinForm控件將在 顯示工具箱 enter image description hereenter image description here
  • 將一個GeckoWebBrowser控制WinForm設計,讓我們 稱之爲「瀏覽」 enter image description here
  • 在Form1.cs文件,添加如下代碼: enter image description here 終於CODE:

      using System; 
         using System.Collections.Generic; 
         using System.ComponentModel; 
         using System.Data; 
         using System.Drawing; 
         using System.Linq; 
         using System.Text; 
         using System.Windows.Forms; 
         using System.Drawing.Printing; 
    
         namespace GECKO_FORMS 
         { 
          public partial class Form1 : Form 
          { 
           Bitmap bitmap; 
           Bitmap memoryImage; 
           public Form1() 
           { 
            InitializeComponent(); 
            Gecko.Xpcom.Initialize(@"D:\\xulrunner\bin\\"); 
           }    
           private void cmdbrowse_Click(object sender, EventArgs e) 
           { 
            try 
            { 
             if (browse.IsBusy == false) 
             { 
              browse.Navigate(textBox1.Text); 
             } 
             else 
             { 
              lbox.Items.Add(browse.StatusText); 
              lbox.Items.Add(browse.History); 
             }    
            } 
            catch (Exception ex) 
            { 
             MessageBox.Show(ex.Message); 
            } 
           } 
    
           private void cmdstop_Click(object sender, EventArgs e) 
           { 
            browse.Stop(); 
           } 
    
                       private void browse_ProgressChanged(object sender, Gecko.GeckoProgressEventArgs e) 
    { 
        lbox.Items.Add(e.CurrentProgress + " of " + e.MaximumProgress); 
    } 
                                       private void CaptureScreen() 
    { 
        Graphics myGraphics = this.CreateGraphics(); 
        Size s = this.Size; 
        memoryImage = new Bitmap(s.Width, s.Height, myGraphics); 
        Graphics memoryGraphics = Graphics.FromImage(memoryImage); 
        memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s); 
    } 
    
                                                                                                               private void cmdprint_Click(object sender, EventArgs e) 
    { 
        try 
        { 
         CaptureScreen(); 
         pDoc.Print(); 
         ////Add a Panel control. 
         //Panel panel = new Panel(); 
         //this.Controls.Add(panel); 
         ////Create a Bitmap of size same as that of the Form. 
         //Graphics grp = panel.CreateGraphics(); 
         //Size formSize = this.ClientSize; 
         //bitmap = new Bitmap(formSize.Width, formSize.Height, grp); 
         //grp = Graphics.FromImage(bitmap); 
    
         ////Copy screen area that that the Panel covers. 
         //Point panelLocation = PointToScreen(panel.Location); 
         //grp.CopyFromScreen(panelLocation.X, panelLocation.Y, 0, 0, formSize); 
    
         ////Show the Print Preview Dialog. 
         //ppd.Document = pDoc; 
         //ppd.PrintPreviewControl.Zoom = 1; 
         //ppd.ShowDialog(); 
        } 
        catch (Exception ex) 
        { 
        } 
    }   
    
                       private void pDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) 
    { 
        e.Graphics.DrawImage(bitmap, 0, 0); 
    } 
          } 
         } 
    
  • 這裏是輸出: enter image description here

+0

順便說一句,如果唯一的原因不使用WebBrowser控件的原因是它沒有正確顯示站點,請查看[此帖子](http://stackoverflow.com/a/38514446/3110834)。希望你覺得它有幫助:) –