C# 开发了简单的winform应用程序,使用gecko,won';我不能在另一台计算机上运行

C# 开发了简单的winform应用程序,使用gecko,won';我不能在另一台计算机上运行,c#,gecko,C#,Gecko,我开发了一个简单的windows窗体应用程序,可以在Gecko浏览器中显示网页。它在我的计算机上运行良好(win10,visual st.2017),我也在另一台运行win10的计算机上尝试过,它也运行良好,但当我尝试在客户端的计算机上运行它时,它不会启动,好像什么都没有发生,光标会变成一个圆圈(思考),然后什么都没有 我安装了.net 4.6没有更改,禁用了防病毒没有更改,安装了firefox没有更改。尝试了另一个winforms应用程序,它只是打开了一个空窗口,工作正常,另一个控制台应用程序

我开发了一个简单的windows窗体应用程序,可以在Gecko浏览器中显示网页。它在我的计算机上运行良好(win10,visual st.2017),我也在另一台运行win10的计算机上尝试过,它也运行良好,但当我尝试在客户端的计算机上运行它时,它不会启动,好像什么都没有发生,光标会变成一个圆圈(思考),然后什么都没有

我安装了.net 4.6没有更改,禁用了防病毒没有更改,安装了firefox没有更改。尝试了另一个winforms应用程序,它只是打开了一个空窗口,工作正常,另一个控制台应用程序工作正常,只是这个应用程序使用Gecko webbrowser无法工作

我试着简单地复制我的bin\debug文件夹并运行该应用程序,我还试着在发布版本也无法运行后从setup.exe安装该应用程序,它给出了一个错误,即找不到plugin-hang-ui.deploy.exe,我在Firefox文件夹的bin\release下有plugin-hang-ui.exe

我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;
using Gecko;

namespace ScreenPlayer1
{
public partial class Form1 : Form
{
    static string serial = "thefirst1";//This is unique per user.
    private const int SW_HIDE = 0;
    private const int SW_SHOW = 1;
    [DllImport("user32.dll")]
    private static extern int FindWindow(string className, string windowText);
    [DllImport("user32.dll")]
    private static extern int ShowWindow(int hwnd, int command);
    int hWnd = FindWindow("Shell_TrayWnd", "");
    string UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0";
    public Form1()
    {
        InitializeComponent();
        Xpcom.Initialize("Firefox");
        GeckoPreferences.User["full-screen-api.enabled"] = true;
        GeckoPreferences.Default["full-screen-api.enabled"] = true;
        GeckoPreferences.User["general.useragent.override"] = UserAgent;
        GeckoPreferences.Default["general.useragent.override"] = UserAgent;
        WindowState = FormWindowState.Maximized;
        TopMost = true;

    }

    /// <summary>
    /// //hash stuff
    /// </summary>
    static string ComputeSha256Hash(string rawData, string salt)
    {
        // Create a SHA256   
        using (SHA256 sha256Hash = SHA256.Create())
        {
            string salted = "6++6" + rawData + salt;
            // ComputeHash - returns byte array  
            byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(salted));

            // Convert byte array to a string   
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < bytes.Length; i++)
            {
                builder.Append(bytes[i].ToString("x2"));
            }
            return builder.ToString();
        }
    }
    /// <summary>
    /// end hash stuff
    /// </summary>
    /// 


    private void Form1_Load(object sender, EventArgs e)
    {
        Random r = new Random(), s = new Random(), t = new Random();
        string salt = "s" + r.Next(1, 100) + s.Next(1, 100) + t.Next(1, 100);
        string get_serial = ComputeSha256Hash(serial, salt);
        string mode = "client";

        if (!File.Exists("mode.txt"))
        {
            string message = "Set as server?", caption = "Mode not set, choose yes for server no for client!";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult result;

            // Displays the MessageBox.

            result = MessageBox.Show(message, caption, buttons);
            if (result == DialogResult.Yes)
            {
                mode = "server";
                System.IO.File.WriteAllText(@"mode.txt", mode);
            }
            else
            {
                mode = "client";
                System.IO.File.WriteAllText(@"mode.txt", mode);
            }
        }
        else
        {
            mode = System.IO.File.ReadAllText(@"mode.txt");
        }

        if (mode == "client")
        {
            int hh = ShowWindow(hWnd, SW_SHOW);
            FormBorderStyle = FormBorderStyle.None;
        }
        try
        {
            geckoWebBrowser2.Navigate("http://www.example.com/scr/prl.php?usr="                               
                               + get_serial + "&sts=" + salt + "&mode=" + mode);
            geckoWebBrowser2.Width = geckoWebBrowser2.Parent.Width;
            geckoWebBrowser2.Height = geckoWebBrowser2.Parent.Height;
        }
        catch (Exception sysEx)
        {
            System.Diagnostics.EventLog.WriteEntry("Bad web browsing!", sysEx.ToString());
        }
    }

    private void Form1_Closing(object sender, FormClosingEventArgs e)
    {
        int hwnd = ShowWindow(hWnd, SW_SHOW);
    }

    private void geckoWebBrowser2_Click(object sender, EventArgs e)
    {

    }
}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows.Forms;
使用System.Security.Cryptography;
使用System.Runtime.InteropServices;
使用Microsoft.Win32;
使用System.IO;
使用壁虎;
命名空间屏幕播放器1
{
公共部分类Form1:Form
{
静态字符串serial=“thefirst1”//这是每个用户唯一的。
私有常量int SW_HIDE=0;
私人康斯特国际软件展=1;
[DllImport(“user32.dll”)]
私有静态外部程序int FindWindow(字符串类名称,字符串windowText);
[DllImport(“user32.dll”)]
私有静态外部显示窗口(inthwnd,int命令);
int-hWnd=FindWindow(“Shell_-TrayWnd”);
字符串UserAgent=“Mozilla/5.0(Windows NT 6.1;Win64;x64;rv:65.0)Gecko/20100101 Firefox/65.0”;
公共表格1()
{
初始化组件();
初始化(“Firefox”);
GeckoPreferences.User[“全屏api.enabled”]=true;
GeckoPreferences.Default[“全屏api.enabled”]=true;
GeckoPreferences.User[“general.useragent.override”]=useragent;
GeckoPreferences.Default[“general.useragent.override”]=useragent;
WindowState=FormWindowState.Maximized;
最顶端=真;
}
/// 
/////散列
/// 
静态字符串计算ha256hash(字符串rawData、字符串salt)
{
//创建一个SHA256
使用(SHA256 sha256Hash=SHA256.Create())
{
字符串salted=“6++6”+原始数据+盐;
//ComputeHash-返回字节数组
byte[]bytes=sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(salted));
//将字节数组转换为字符串
StringBuilder=新的StringBuilder();
for(int i=0;i
  • [process]相关文章推荐