IDocHostUIHandler使MSHTML.dll崩溃,错误0xc0000409 [英] IDocHostUIHandler crashing MSHTML.dll with error 0xc0000409

查看:135
本文介绍了IDocHostUIHandler使MSHTML.dll崩溃,错误0xc0000409的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自 https://stackoverflow.com的稍加修改的 IDocHostUIHandler / a / 21699086/592212 在一个简单的主窗口测试应用程序中,该窗口中只有WPF WebBrowser 组件。初始化代码如下:

I am using slightly modified IDocHostUIHandler from https://stackoverflow.com/a/21699086/592212 in simple one main window test application with only WPF WebBrowser component in that Window. The initialization code is as follows:

    public MainWindow()
    {
        InitializeComponent();

        _wbHostHandler = new WebBrowserHostUIHandler(PART_WebBrowser);
        _wbHostHandler.Flags |= HostUIFlags.DpiAware;

        PART_WebBrowser.Navigate("SOME_URL");
    }

应用程序中实际上没有任何其他操作。尽管如此,运行该应用程序后,COM组件中仍引发错误(因此,我无法使用调试器来捕获它),并且在事件查看器中报告了0xc0000409( STATUS_STACK_BUFFER_OVERRUN

There is really nothing else going on in the Application. Still, after running the application, an error is thrown in COM component (therefore, I can not use a debugger to trap it) and 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN) is reported in Event Viewer.

关于导致错误或如何消除该错误的任何想法?

Any ideas of what is causing the error or how to get rid of it?

(Win10 Pro 1703(内部版本15063.483)和.NET 4.6.2)

(Win10 Pro 1703 (build 15063.483) and .NET 4.6.2)

源代码: https://www.dropbox.com/s/ddob6p7jh4dfsda/UIHostCrashDemo.zip?dl=1

推荐答案

我不知道您从何处获得WebBrowserHostUIHandler.cs内容,但这是错误 IDocHostUIHandler 的定义只是错过了 TranslateAccelerator 方法。

I don't know where you got your WebBrowserHostUIHandler.cs content from but it's wrong. The definition of IDocHostUIHandler simply misses the TranslateAccelerator method.

我猜是因为我的初始代码使用了System.Windows.Forms.Message类型,该类型是对System.Windows.Forms(winforms)程序集的引用。如果这是一个问题,那么如果不使用消息(在我的初始代码中是这种情况),则可以用此方法代替。

I guess it's because my initial code used System.Windows.Forms.Message type which is a reference to the System.Windows.Forms (winforms) assembly. If this is such a problem, the method can just be replaced by this if the message is not used (wich is the case in my initial code).

所以在界面,您必须在 ResizeBorder 之后添加此内容:

So in the interface you must add this, just after ResizeBorder:

[PreserveSig]
uint TranslateAccelerator(IntPtr msg, ref Guid group, int nCmdID);

您必须在代码中的任何地方实现它,例如:

And you must implement it anywhere in the code, like this:

uint Native.IDocHostUIHandler.TranslateAccelerator(IntPtr msg, ref Guid group, int nCmdID)
{
    return S_FALSE;
}

但是,这是可选的,如果您想要可以仔细复制的东西/从我的帖子中粘贴我的代码,并在需要时添加对System.Windows.Forms的引用。

But again, this is optional, if you want something that works just carefully copy/paste my code from my post and add a reference to System.Windows.Forms if needed.

这篇关于IDocHostUIHandler使MSHTML.dll崩溃,错误0xc0000409的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆