CEF - Embedded Chromium - C# Windows Form does not run on another machine

0

I have created an empty windows form application called "WindowsFormsApp2". To it I added the following Nuget packages:

Microsoft.Toolkit.Forms.UI.Controls.WebView.5.1.1

RestSharp.106.6.10

CefSharp.WinForms.73.1.130

The latter package added the following additional packages:

CefSharp.Common.73.1.130

cef.redist.x64.73.1.13

cef.redist.x86.73.1.13

My app.config is (effectively I enabled the system diagnostic trace):

<?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>

I then added the following code to the form:

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());
    }
}

I compile and run the form without issue on the compiling machine. It writes output to the DebugView application and also creates the output.log file. It opens up the form and it displays www.google.com inside of the browser.

I have a brand new VM with the latest Windows 10 updates including .Net Framework 4.8. I copy the contents of the build directory verbatim over to the new VM and when I run the EXE, there is no visual evidence that it ran. There are no entries to the DebugView window and there are no entries in the output.log file. The only evidence that it ran are 3 new window's event application logs.

Error - Event 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()

Error - Event 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: 

Information - Event 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

If I remove the references to CEF from the form, then the form opens on both machines without issues. There is clearly some file being referenced by the CEF packages that isn't being put in the build directory, but I am not sure how to find out what it is.

Any ideas?

Thanks a bunch.

c#
winforms
chromium-embedded
asked on Stack Overflow Aug 6, 2019 by Garet Jax

1 Answer

1

CEF is dependent on Microsoft Visual C++ 2015 Redistributable. Somehow missed that requirement.

answered on Stack Overflow Aug 6, 2019 by Garet Jax

User contributions licensed under CC BY-SA 3.0