I developed a simple windows form app that displays a webpage inside a Gecko webrowser. It works fine on my computer(win10, visual st.2017), I also tried it on another computer running win10 and it also runs fine, but when I tried running it on the client's computer it just won't launch, as if nothing happens, the cursor changes to a circle(thinking) and then nothing.
I installed .net 4.6 no change, disabled antivirus no change, installed firefox no change. Tried another winforms app that simply opens an empty window and it works fine, and another console application works fine, it's just this app that uses Gecko webbrowser that doesn't work.
I tried simply copying my bin\debug folder and running the app, and I also tried installing the app from the setup.exe after making a release version also won't run, it gives error that plugin-hang-ui.deploy.exe not found, I have plugin-hang-ui.exe in Firefox folder under bin\Release.
My code:
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)
{
}
}
}
Help would be appreciated, thanks.