Rank: Newbie Groups: Member
Joined: 7/3/2017 Posts: 8
|
Hi We have a WPF app and a 'dashcam' taking screen shots every 100 ms or so. Occasionally we get the exception :
TakePhoto Exception at frame 57:
System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at EO.WebBrowser.WebView.a(IntPtr A_0, Int32 A_1, Int32 A_2) at EO.WebBrowser.WebView.b(IntPtr A_0, Int32 A_1, Int32 A_2) at EO.WebBrowser.WebView.Capture(Rectangle srcRect, Size targetSize) at EO.WebBrowser.WebView.Capture(Rectangle srcRect) at EO.WebBrowser.WebView.Capture(Boolean excludeScrollBars) at EO.WebBrowser.WebView.Capture() at ScrapeLib.DashCam.TakePhoto(WebView webView)
We thought it was a startup issue, but turns out its not as its taken 57 frames successfully. Code is:
if (!webView.IsReady || !webView.IsCreated) { Trace.WriteLine($"No Photo IsReady={webView.IsReady} IsCreated={webView.IsCreated}"); return; } try { var pic = webView.Capture();
Trace Log: first two frames get:
No Photo IsReady=False IsCreated=False No Photo IsReady=False IsCreated=True
Is there anything else we can test for to avoid the exception?
Thanks
Justin
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
This usually indicates a low memory issue. Please check to make sure you call Dispose of the returned Image object. If that still does not work, you may want to reduce the frame rate.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 7/3/2017 Posts: 8
|
Thanks, I'll give that a try.
|