Home > Net >  Small white reached a question, about the CEF, invoke devtools screenshots operation error
Small white reached a question, about the CEF, invoke devtools screenshots operation error

Time:12-19

In WinForm added a CEF controls (with the code to add useless designer), and then in the Form of code added invokeCapture attribute, the hope is that this approach to CEF screenshots of the whole page, the first screenshot is normal, but from the second screenshot has been an error, also cut out, an error Message is "Generated MessageID 100002 doesn 't match returned Message Id 100001", is there any way we can capture,

I put the lot cefsharp that DevToolsExtensions. Cs to come in the code is copied to the project, and also change the namespace,

Inside the DevToolsClient lastMessageId variables are private, didn't also a getter and setter, the variable inside the CaptureScreenshot method performs ExecuteDevToolsMethodAsync statement when used, it's very annoying, ExecuteDevToolsMethodAsync to take this class lastMessageId and execution ExecuteDevToolsMethod method returns the message ID of the comparison, if not the same as would be an error and force to terminate execution, CEF GetDevToolsClient method also looked at the controls, this method is actually the new object directly, is making the sample code line 36, and this new object after lastMessageId assignment is relative to the CEF is written death,

The question I asked in StackOverflow too, the most there is no reply, no one thumb up point on, don't know if CSDN side have bosses would solve this,

 private async void invokeCapture () 
{
Try
{
Byte [] result=await winformcefdemo. CefSharp. Example. DevTools. DevToolsExtensions. CaptureScreenShotAsPng (browser);

//task. Start ();
//byte [] result=task. The result;
SaveFileDialog dialog=new SaveFileDialog ();
DialogResult dresult=dialog. ShowDialog ();
If (dresult==DialogResult. OK)
{
String path=dialog. The FileName;
Try
{
File. WriteAllBytes (path, result);
MessageBox. Show (path + saved "success");
} the catch (Exception e)
{
MessageBox. Show (path + "Unknown error occurred when saving to file:" + e.M essage);
}
}
}
The catch (Exception ee)
{
MessageBox. Show (" Unknown error occurred when capturing: "+ ee. The Message).
}
}
  • Related