2016-07-23 4 views
0

Мне была задана задача интегрировать компонент браузера Gecko в существующий элемент управления winform, но проблема, с которой сталкивается проблема, заключается в том, как настроить DLL, я пытаюсь использовать другую версию как хорошо, но не повезло, в точке она не загружает DLL и выдает ошибкуКак настроить «Gecko» с помощью приложения форм Vb.NET

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 Импорт Gecko Импорт Microsoft.Win32

Public Class 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.0 и XULRunner 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 Gecko будет показано в в окне инструментов enter image description hereenter image description here
  • Перетащите управление GeckoWebBrowser дизайнера Winform, и давайте называть его «просмотреть» enter image description here
  • В файле Form1.cs, добавьте ниже код: enter image description here И НАКОНЕЦ КОД:

      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). Надеюсь, вам понравится :) –

 Смежные вопросы

  • Нет связанных вопросов^_^