2016-07-23 43 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)。希望你觉得它有帮助:) –