简体   繁体   English

Winforms中的WPF ElementHost在最大化时崩溃(Windows)

[英]WPF ElementHost in Winforms crashes (Windows) when Maximized

I'm trying to integrate a new WPF control into an existing WinForms application and I'm using an ElementHost(Dock-Fill) to host the following XAML UserControl. 我正在尝试将新的WPF控件集成到现有的WinForms应用程序中,并且我正在使用ElementHost(Dock-Fill)来托管以下XAML UserControl。 (.NET 4) (.NET 4)

When I set the WinForm to Maximised my entire operating system crashes. 当我将WinForm设置为最大化时,我的整个操作系统崩溃了。 I have updated to the latest NVidia Drivers for my video card, but I still end up with a BlueScreen in nvlddmkm.sys. 我已更新到我的视频卡的最新NVidia驱动程序,但我仍然在nvlddmkm.sys中使用BlueScreen。 I have searched around for others that are experiencing crashes like this, but haven't found anything other than "update video card drivers". 我一直在寻找其他正在经历此类崩溃的人,但除了“更新视频卡驱动程序”之外还没有找到任何其他内容。

The CustomerOrderReadyControl specified in the UserControl is in C#, but given it's just a basic UserControl that displays the Message I haven't included it, but if you think I should, please specify in the comments. UserControl中指定的CustomerOrderReadyControl在C#中,但是它只是一个基本的UserControl,它显示了我没有包含它的消息,但如果您认为我应该,请在注释中指定。

Is there a setting that I am missing that could be causing my Application to be causing the Machine to bluescreen when I maximise the Form? 是否有一个我错过的设置可能导致我的应用程序在我最大化表单时导致机器蓝屏? Are there any other ways that I could make this scenario work given that the existing application is very heavy GDI+ for the rendering of other parts of the application? 鉴于现有应用程序是非常重的GDI +用于呈现应用程序的其他部分,还有其他方法可以使这个场景工作吗?

<UserControl x:Class="WPFDisplay.CustomerOrderDisplayControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="480" d:DesignWidth="640" xmlns:my="clr-namespace:WPFDisplay">
    <UserControl.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <GradientStop Color="#FFEEEEEE" Offset="0.05"/>
            <GradientStop Color="#FF333333" Offset="0.95"/>
        </LinearGradientBrush>
    </UserControl.Background>
        <Grid Name="mainGrid">

        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition  Name="imageRow" Height="125" />
        </Grid.RowDefinitions>

        <my:CustomerOrderReadyControl Grid.Row="0"  x:Name="customerOrderReadyControl1" 
               Message="The Message" />
        <Image Margin="0,0,6,7" Name="displayLogo" Grid.Row="1" VerticalAlignment="Bottom" 
               HorizontalAlignment="Right" Width="302" Height="107" Stretch="None" IsHitTestVisible="False" />
    </Grid>
</UserControl>

The InitializeComponent sub in my WinForms is really this simple. 我的WinForms中的InitializeComponent子实际上非常简单。

Private Sub InitializeComponent()
    Me.ElementHost1 = New System.Windows.Forms.Integration.ElementHost()
    Me.CustomerOrderDisplayControl1 = New WPFDisplay.CustomerOrderDisplayControl()
    Me.SuspendLayout()
    '
    'ElementHost1
    '
    Me.ElementHost1.Dock = System.Windows.Forms.DockStyle.Fill
    Me.ElementHost1.Location = New System.Drawing.Point(0, 0)
    Me.ElementHost1.Name = "ElementHost1"
    Me.ElementHost1.Size = New System.Drawing.Size(1058, 617)
    Me.ElementHost1.TabIndex = 0
    Me.ElementHost1.Text = "ElementHost1"
    Me.ElementHost1.Child = Me.CustomerOrderDisplayControl1
    '
    'CustomerOrderDisplayForm
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(1058, 617)
    Me.Controls.Add(Me.ElementHost1)
    Me.Name = "CustomerOrderDisplayForm"
    Me.Text = "CustomerOrderDisplayForm"
    Me.ResumeLayout(False)

End Sub

EDIT: Additional info.. If I host this control in a Pure WPF application and maximise the WPF Form, then it all works fine. 编辑:附加信息..如果我在Pure WPF应用程序中托管此控件并最大化WPF表单,那么一切正常。

Turns out this was the video card (NVidia NVS295) just not handling the WPF operations. 原来这是视频卡(NVidia NVS295)只是没有处理WPF操作。 It ended up not mattering whether it was in a full blown WPF application or embedded inside an ElementHost if the screen display full screen (1900x1200) then the machine bluescreened. 最终无论是在完整的WPF应用程序中还是嵌入在ElementHost中,如果屏幕显示全屏(1900x1200),那么机器都会进行蓝屏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM