Welcome Guest Search | Active Topics | Sign In | Register

NullRefException in WebViewHost Options
Commend International
Posted: Monday, May 8, 2023 10:50:03 AM
Rank: Newbie
Groups: Member

Joined: 5/2/2023
Posts: 2
From time to time we get an unhandled NRE.
Unfortunately we are not able to reproduce this in a sample app.

All we actually have is the stacktrace.

at EO.Wpf.WebViewHost.oear.Dispose(Boolean disposing)
at System.Windows.Interop.HwndHost.Finalize()


Our app constantly adds or removes new EO.Wpf.WebControl instances.
Before removing an instance we call
WebControl.WebView.Destroy();
WebControl.WebView = null;


Maybe you can give us a hint what is going wrong here or provide an update to handle the NRE in the Dispose method of the WebViewHost.
eo_support
Posted: Monday, May 8, 2023 11:53:24 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

This appears to be an issue on our end. Please do NOT explicitly call WebControl.WebView.Destroy() and see if that resolves the issue for you. The WebView will be automatically destroyed when the containing WPF window is destroyed, as such there is no need to call WebView.Destroy explicitly.

Thanks!
Commend International
Posted: Tuesday, May 9, 2023 4:05:17 AM
Rank: Newbie
Groups: Member

Joined: 5/2/2023
Posts: 2
Waiting for automatic cleanup is not an option. As the owner window may never closes.
eo_support
Posted: Tuesday, May 9, 2023 10:22:01 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Please call the WebControl's Dispose instead. For example, in the TabbedBrowser sample application you can do something like this when a tab is closed:

Code: C#
//Get the object that contains information about a tab
WebViewItem item = (WebViewItem)m_WebViewsHost.Items[index];

//Remove the tab from the visual tree
m_WebViewsHost.Items.RemoveAt(index);

//Call WebControl's Destroy method. This will destroy the WebView
item.Page.WebControl.Destroy();


The key is do not touch WebControl.WebView.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.