简体   繁体   English

C#-具有Gecko和xul的Windows窗体

[英]C# - Windows forms with Gecko and xul

I've some problem with integrating Gecko in C# with XUL. 我在将Gecko与XUL集成到C#中时遇到一些问题。

1/I've downloaded geckofx45.45.0.34.nupkg. 1 /我已经下载了geckofx45.45.0.34.nupkg。 With that, I've renamed its extension in '.zip' and unzipped this folder. 这样,我将其扩展名重命名为“ .zip”,并解压缩了该文件夹。 I've got many directory. 我有很多目录。

2/Then, I've created a windows forms application in C# (.NET Framework 4.5.2). 2 /然后,我在C#(.NET Framework 4.5.2)中创建了一个Windows窗体应用程序。 Through 'solution explorer', I've added two libraries (Geckofx-Core.dll and Geckofx-Winforms.dll) generated by step 1 通过“解决方案资源管理器”,我添加了第1步生成的两个库(Geckofx-Core.dll和Geckofx-Winforms.dll)

3/Then, in the toolbox , on 'All Windows Forms' collapse, I've done a right click and 'Choose Items'. 3 /然后,在工具箱的“所有Windows窗体”折叠中,我单击了鼠标右键并选择了“选择项目”。 Then, in '.NET Framework Components' tab, I've added Geckofx-Winforms.dll. 然后,在“ .NET Framework组件”选项卡中,添加了Geckofx-Winforms.dll。

4/I've restarted Visual Studio 2015 4 /我已经重新启动了Visual Studio 2015

5/Then, I've opened again my project and added a 'GeckoBrowser' component from the toolbox to my window. 5 /然后,我再次打开我的项目,并在工具箱中向窗口添加了“ GeckoBrowser”组件。

6/Then, I've compiled my project. 6 /然后,我已经编译了我的项目。 It's all right. 没关系。 But, when I've tried to execute my application, I've had a problem : 但是,当我尝试执行我的应用程序时,我遇到了一个问题:

An unhandled exception of type 'System.DllNotFoundException' occurred in Geckofx-Core.dll
Additional information: Unable to load DLL 'xul': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

So, I've downloaded xulrunner on http://ftp.mozilla.org/pub/xulrunner/releases/latest/runtimes/xulrunner-41.0.2.en-US.win32.zip and unzipped the file. 因此,我已经在http://ftp.mozilla.org/pub/xulrunner/releases/latest/runtimes/xulrunner-41.0.2.en-US.win32.zip下载了xulrunner并解压缩了文件。 Result : C:\\xulrunner\\xulrunner-41.0.2.en-US.win32\\xulrunner\\ 结果:C:\\ xulrunner \\ xulrunner-41.0.2.en-US.win32 \\ xulrunner \\

7/ Then, in the properties of my project, in 'Reference Paths', I've added the path C:\\xulrunner\\xulrunner-41.0.2.en-US.win32\\xulrunner\\ 7 /然后,在项目的属性中的“参考路径”中,添加了路径C:\\ xulrunner \\ xulrunner-41.0.2.en-US.win32 \\ xulrunner \\

8/ I've launched again my application and always the same error on the screen 8 /我再次启动了应用程序,并且在屏幕上始终出现相同的错误

I've also tried to use 'TlbImp.exe' without success. 我也尝试过使用“ TlbImp.exe”而没有成功。

Can you help me ? 你能帮助我吗 ?

The approach that I use requires dropping the xulrunner folder into the app folder and then using this method: 我使用的方法需要将xulrunner文件夹拖放到app文件夹中,然后使用此方法:

private void InitializeGeckoEngine()
    {

        try
        {
            if (!Directory.Exists(Paths.XulRunner))
            {
                MessageBox.Show($"Firefox folder not found at {Paths.XulRunner}!");
            }

            Xpcom.EnableProfileMonitoring = false;
            Xpcom.Initialize(Paths.XulRunner);

        }
        catch (Exception ex)
        {
            MessageBox.Show($"Firefox engine not detected or was not loaded correctly. Loading path: {Paths.XulRunner}. Exception details:\n" + ex + ex.InnerException, "Error",
                MessageBoxButton.OK, MessageBoxImage.Error);

        }
    }

The key part is of course the Xpcom.Initialize() call. 关键部分当然是Xpcom.Initialize()调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM