-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
63 lines (58 loc) · 2.24 KB
/
Program.cs
File metadata and controls
63 lines (58 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.IO;
using System.Windows.Forms;
namespace GeckoBrowser
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main(string[] args)
{
// FormBrowserHostから起動された時は引数に通信用URLが渡される
if (args.Length == 0)
{
MessageBox.Show("これは七四式電子観測儀のサブプログラムであり、単体では起動できません。\r\n本体から起動してください。",
"情報", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
Application.Run(new FormBrowser(args[0]));
}
private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.StartsWith("CefSharp"))
{
string asmname = args.Name.Split(",".ToCharArray(), 2)[0] + ".dll";
string arch = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Environment.Is64BitProcess ? "x64" : "x86", asmname);
if (!System.IO.File.Exists(arch))
return null;
try
{
return System.Reflection.Assembly.LoadFile(arch);
}
catch (IOException ex) when (ex is FileNotFoundException || ex is FileLoadException)
{
if (MessageBox.Show(
$@"ブラウザコンポーネントがロードできませんでした。動作に必要な
「Microsoft Visual C++ 2015 再頒布可能パッケージ」
がインストールされていないのが原因の可能性があります。
ダウンロードページを開きますか?
(vc_redist.{(Environment.Is64BitProcess ? "x64" : "x86")}.exe をインストールしてください。)",
"CefSharp ロードエラー", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
== DialogResult.Yes)
{
System.Diagnostics.Process.Start(@"https://www.microsoft.com/ja-jp/download/details.aspx?id=53587");
}
// なんにせよ今回は起動できないのであきらめる
throw;
}
}
return null;
}
}
}