Reputation: 149
In a C# .Net 4.7.2 WPF project, I'm loading the GeckoWebBrowser component from a UserControl. I'm using the nuget package id="Geckofx60.64" version="60.0.18" .
My solution and project are configured with "Any CPU" in VS2017.
In order to get the Firefox64 repository, I add the nuget package id="Geckofx60.64.Windows" version="0.7.0".
Everything is OK, then I'm calling an "index.html" page with the following code
public partial class Simulator : UserControl
{
readonly string indexPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates", "index.html");
private GeckoWebBrowser _browser;
public Simulator()
{
InitializeComponent();
Xpcom.Initialize("Firefox64");
var host = new WindowsFormsHost();
_browser = new GeckoWebBrowser();
host.Child = _browser;
GridWeb.Children.Add(host);
}
private void Datacontext_ConfigurationChanged(object sender, System.EventArgs e)
{
Dispatcher.Invoke(() =>
_browser.Navigate(indexPath)
);
}
private void Simulator_OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var datacontext = DataContext as ServicesViewModel;
if (datacontext != null)
{
datacontext.ConfigurationChanged -= Datacontext_ConfigurationChanged;
datacontext.ConfigurationChanged += Datacontext_ConfigurationChanged;
}
}
}
The logic in my application is to refresh the browser each time I have some changes in my local objects.
Datacontext_ConfigurationChanged
will be called for each change.
It's working pretty well except that I can receive this exception randomly during a refresh
"System.AccessViolationException: Attempted to read or write protected memory.."
This exception crashes my app, and I can't find any solution for this exception. Thank you for your help !
Upvotes: 0
Views: 855