I'm using the Awesomium plugin in C# (.NET 4.0) and am getting "Program has stopped working" error message when closing the problem. I believe it is due to the Awesomium process that is being killed.

I've used advice from Stack Overflow quesdtion I get “has stopped working” error when I use 'Application.Exit();' in C#:

WebCore.Shutdown();

// Erase all temporary files
Process process = Process.Start(@"rmdir /s/q " + "Cache");
process.WaitForExit();
Application.Exit();

I get AccessViolationException. How do I solve this?

有帮助吗?

解决方案

I suspect the problem is the process.WaitForExit(); line or passing a relative file path instead of an absolute file path.

WebCore.Shutdown();
DeleteCache();
Application.Exit();

// ...

private void DeleteCache()
{
  ProcessStartInfo info = new ProcessStartInfo();
  // get the full path to the Awesomium cache directory
  string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cache");
  string command = String.Format("RMDIR /S /Q \""{0}\"", path);

  // get the path to cmd.exe
  info.FileName = System.Environment.GetEnvironmentVariable("COMSPEC") ?? "cmd.exe";

  // append the cmd.exe flags to disable auto-run scripts (/D) and to exit at completion (/C)
  info.Arguments = String.Concat("/D /C ", command);
  info.WindowStyle = ProcessWindowStyle.Hidden;

  // start the process without waiting for completion
  Process.Start(info);
}

I also don't understand why Awesomium runs their own clone of SO with Awesomium Answers. Awesomium could just simply monitor questions tagged as awesomium. The Anwsers forum is even more frustrating given the irregular involvement of the Awesomium LLC developers.

其他提示

I had this same problem with the Chromium Embedded Framework (CEF). I solved it by calling:

process.Kill ();

in the FormClosing () handler.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top