CEF - 嵌入式 Chromium - C# Windows 表单在另一台机器上不 运行
CEF - Embedded Chromium - C# Windows Form does not run on another machine
我创建了一个名为 "WindowsFormsApp2" 的空 windows 表单应用程序。我向其中添加了以下 Nuget 包:
Microsoft.Toolkit.Forms.UI.Controls.WebView.5.1.1
RestSharp.106.6.10
CefSharp.WinForms.73.1.130
后一个包添加了以下附加包:
CefSharp.Common.73.1.130
cef.redist.x64.73.1.13
cef.redist.x86.73.1.13
我的 app.config 是(实际上我启用了系统诊断跟踪):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="log" type="System.Diagnostics.TextWriterTraceListener" initializeData="output.log" />
</listeners>
</trace>
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
然后我将以下代码添加到表单中:
public partial class Form1 : Form {
private ChromiumWebBrowser chromeWebBrowser = null;
public Form1() {
try {
Debug.WriteLine("Got here0");
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
Debug.WriteLine("Got here1");
InitializeComponent();
Debug.WriteLine("Got here2");
Cef.Initialize(new CefSettings());
Debug.WriteLine("Got here3");
this.chromeWebBrowser = new ChromiumWebBrowser("");
Debug.WriteLine("Got here4");
this.Controls.Add(chromeWebBrowser);
Debug.WriteLine("Got here5");
this.chromeWebBrowser.Dock = DockStyle.None;
Debug.WriteLine("Got here6");
this.chromeWebBrowser.Height = Screen.GetWorkingArea(this).Height;
Debug.WriteLine("Got here7");
this.chromeWebBrowser.Width = Screen.GetWorkingArea(this).Width;
Debug.WriteLine("Got here8");
this.chromeWebBrowser.Load("https://www.google.com");
Debug.WriteLine("Got here9");
} catch (Exception e) {
Debug.WriteLine("Exception: " + e.ToString());
} // try catch
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args) {
Exception e = (Exception)args.ExceptionObject;
Debug.WriteLine("Unhandled Exception: " + e.ToString());
}
}
我在编译机器上编译并运行表格没有问题。它将输出写入 DebugView 应用程序并创建 output.log 文件。它会打开表单并在浏览器中显示 www.google.com。
我有一个 b运行d 新 VM,其中包含最新的 Windows 10 个更新,包括 .Net Framework 4.8。我将构建目录的内容逐字复制到新 VM,当我 运行 EXE 时,没有视觉证据表明它 运行。 DebugView window 中没有条目,output.log 文件中也没有条目。 运行 的唯一证据是 3 个新的 window 事件应用程序日志。
错误 - 事件 ID 1026:
Application: WindowsFormsApp2.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at WindowsFormsApp2.Form1..ctor()
at WindowsFormsApp2.Program.Main()
错误 - 事件 ID 1000
Faulting application name: WindowsFormsApp2.exe, version: 1.0.0.0, time stamp: 0xa390557a
Faulting module name: KERNELBASE.dll, version: 10.0.18362.267, time stamp: 0xf09944f9
Exception code: 0xe0434352
Fault offset: 0x000000000003a839
Faulting process id: 0x1c08
Faulting application start time: 0x01d54c7eda2259ba
Faulting application path: C:\Temp\FormApp\WindowsFormsApp2.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 181886c1-19f4-4931-91b1-95af1e001fec
Faulting package full name:
Faulting package-relative application ID:
信息 - 事件 ID 1001:
Fault bucket 1306785398527647396, type 5
Event Name: CLR20r3
Response: Not available
Cab Id: 0
Problem signature:
P1: WindowsFormsApp2.exe
P2: 1.0.0.0
P3: a390557a
P4: WindowsFormsApp2
P5: 1.0.0.0
P6: a390557a
P7: 5
P8: 13
P9: System.IO.FileNotFoundException
P10:
Attached files:
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2DBB.tmp.dmp
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E58.tmp.WERInternalMetadata.xml
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E69.tmp.xml
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E67.tmp.csv
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E87.tmp.txt
These files may be available here:
\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_WindowsFormsApp2_10eb50ab8221721592a26845885856a298fbc16_4defeb0e_c2d699e3-92a1-4aa8-9edd-0573661e017d
Analysis symbol:
Rechecking for solution: 0
Report Id: 181886c1-19f4-4931-91b1-95af1e001fec
Report Status: 268435456
Hashed bucket: bb3bca32b533c2a00222a26574e85ea4
Cab Guid: 0
如果我从表单中删除对 CEF 的引用,则该表单在两台计算机上都可以正常打开。显然有一些 CEF 包引用的文件没有放在构建目录中,但我不确定如何找出它是什么。
有什么想法吗?
非常感谢。
CEF 依赖于 Microsoft Visual C++ 2015 Redistributable。不知何故错过了那个要求。
我创建了一个名为 "WindowsFormsApp2" 的空 windows 表单应用程序。我向其中添加了以下 Nuget 包:
Microsoft.Toolkit.Forms.UI.Controls.WebView.5.1.1
RestSharp.106.6.10
CefSharp.WinForms.73.1.130
后一个包添加了以下附加包:
CefSharp.Common.73.1.130
cef.redist.x64.73.1.13
cef.redist.x86.73.1.13
我的 app.config 是(实际上我启用了系统诊断跟踪):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="log" type="System.Diagnostics.TextWriterTraceListener" initializeData="output.log" />
</listeners>
</trace>
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
然后我将以下代码添加到表单中:
public partial class Form1 : Form {
private ChromiumWebBrowser chromeWebBrowser = null;
public Form1() {
try {
Debug.WriteLine("Got here0");
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
Debug.WriteLine("Got here1");
InitializeComponent();
Debug.WriteLine("Got here2");
Cef.Initialize(new CefSettings());
Debug.WriteLine("Got here3");
this.chromeWebBrowser = new ChromiumWebBrowser("");
Debug.WriteLine("Got here4");
this.Controls.Add(chromeWebBrowser);
Debug.WriteLine("Got here5");
this.chromeWebBrowser.Dock = DockStyle.None;
Debug.WriteLine("Got here6");
this.chromeWebBrowser.Height = Screen.GetWorkingArea(this).Height;
Debug.WriteLine("Got here7");
this.chromeWebBrowser.Width = Screen.GetWorkingArea(this).Width;
Debug.WriteLine("Got here8");
this.chromeWebBrowser.Load("https://www.google.com");
Debug.WriteLine("Got here9");
} catch (Exception e) {
Debug.WriteLine("Exception: " + e.ToString());
} // try catch
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args) {
Exception e = (Exception)args.ExceptionObject;
Debug.WriteLine("Unhandled Exception: " + e.ToString());
}
}
我在编译机器上编译并运行表格没有问题。它将输出写入 DebugView 应用程序并创建 output.log 文件。它会打开表单并在浏览器中显示 www.google.com。
我有一个 b运行d 新 VM,其中包含最新的 Windows 10 个更新,包括 .Net Framework 4.8。我将构建目录的内容逐字复制到新 VM,当我 运行 EXE 时,没有视觉证据表明它 运行。 DebugView window 中没有条目,output.log 文件中也没有条目。 运行 的唯一证据是 3 个新的 window 事件应用程序日志。
错误 - 事件 ID 1026:
Application: WindowsFormsApp2.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at WindowsFormsApp2.Form1..ctor()
at WindowsFormsApp2.Program.Main()
错误 - 事件 ID 1000
Faulting application name: WindowsFormsApp2.exe, version: 1.0.0.0, time stamp: 0xa390557a
Faulting module name: KERNELBASE.dll, version: 10.0.18362.267, time stamp: 0xf09944f9
Exception code: 0xe0434352
Fault offset: 0x000000000003a839
Faulting process id: 0x1c08
Faulting application start time: 0x01d54c7eda2259ba
Faulting application path: C:\Temp\FormApp\WindowsFormsApp2.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 181886c1-19f4-4931-91b1-95af1e001fec
Faulting package full name:
Faulting package-relative application ID:
信息 - 事件 ID 1001:
Fault bucket 1306785398527647396, type 5
Event Name: CLR20r3
Response: Not available
Cab Id: 0
Problem signature:
P1: WindowsFormsApp2.exe
P2: 1.0.0.0
P3: a390557a
P4: WindowsFormsApp2
P5: 1.0.0.0
P6: a390557a
P7: 5
P8: 13
P9: System.IO.FileNotFoundException
P10:
Attached files:
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2DBB.tmp.dmp
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E58.tmp.WERInternalMetadata.xml
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E69.tmp.xml
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E67.tmp.csv
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2E87.tmp.txt
These files may be available here:
\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_WindowsFormsApp2_10eb50ab8221721592a26845885856a298fbc16_4defeb0e_c2d699e3-92a1-4aa8-9edd-0573661e017d
Analysis symbol:
Rechecking for solution: 0
Report Id: 181886c1-19f4-4931-91b1-95af1e001fec
Report Status: 268435456
Hashed bucket: bb3bca32b533c2a00222a26574e85ea4
Cab Guid: 0
如果我从表单中删除对 CEF 的引用,则该表单在两台计算机上都可以正常打开。显然有一些 CEF 包引用的文件没有放在构建目录中,但我不确定如何找出它是什么。
有什么想法吗?
非常感谢。
CEF 依赖于 Microsoft Visual C++ 2015 Redistributable。不知何故错过了那个要求。