首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >anyCPU中的GeckoWebBrowser崩溃

anyCPU中的GeckoWebBrowser崩溃
EN

Stack Overflow用户
提问于 2018-11-14 23:13:42
回答 1查看 713关注 0票数 0

在C# .Net 4.7.2WPF项目中,我从UserControl加载GeckoWebBrowser组件。我使用的是nuget包id="Geckofx60.64“version="60.0.18”。

我的解决方案和项目在VS2017中配置了“任何CPU”。

为了获得Firefox64存储库,我添加了nuget包id="Geckofx60.64.Windows“version="0.7.0”。

一切正常,然后我用以下代码调用一个"index.html“页面

代码语言:javascript
复制
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;
        }
    }
}

我的应用程序中的逻辑是,每当我在本地对象中有一些更改时,都刷新浏览器。

每次更改都会调用Datacontext_ConfigurationChanged

它工作得很好,除了我可以在刷新期间随机接收到这个异常

代码语言:javascript
复制
"System.AccessViolationException: Attempted to read or write protected memory.."

这个异常会导致我的应用程序崩溃,而我找不到任何解决这个异常的方法。感谢您的帮助!

EN

回答 1

Stack Overflow用户

发布于 2018-11-23 23:46:30

我改成了Geckofx45.64,现在没问题了..

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53303342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档