Ryan Christilaw
Ryan Christilaw

Reputation: 79

Opening a WPF Window from a WinForms application (.Net 4.5.2/Win 7/ 32 Bit)

I have recently come across an issue on Windows 7 32-bit OS with .Net 4.5.2 installed. I have an application that is Winforms and opens a modal WPF Window. However, since we installed .Net Framework 4.5.2, these windows do not open properly, once the window .ShowDialog() is called it takes about 15-20 seconds (mouse turns to a pointer for several seconds and the winforms window becomes unresponsive) and then we receive the following exception:

enter image description here System.ComponentModel.Win32Exception (0x80004005): Not enough quota is available to process this command

The weird thing is once this exception is thrown and I choose to "continue", the next time I attempt to open the window, it opens instantly and no exception is thrown.

The following is a simplified version of what I am using to open the window. (When I run this code, the application does not throw the exception but it does hang for the 15-20 seconds)

    private void OpenWpfWindow(object sender, EventArgs e)
    {
        WPFWindow testWindow = new WPFWindow();

        testWindow.Visibility = System.Windows.Visibility.Visible;
        testWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;

        System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(testWindow);
        helper.Owner = System.Windows.Forms.Application.OpenForms[0].Handle;

        testWindow.ShowDialog();
    }

We do not experience this issue with Windows 7 and With .Net 4.5 installed

Upvotes: 3

Views: 874

Answers (1)

Ryan Christilaw
Ryan Christilaw

Reputation: 79

This issue turned out to be an issue in .NET 4.5.2 (in Windows 7) regarding the initialization of touch devices and there is a hotfix solution from Microsoft.

The WPF application starts the Windows Touch Input Service (wisptis.exe), even when no touch devices are present, resulting in a delay, meanwhile the message queue is flooded and the WPF Window creation fails.

The hotfix can be found here: https://support.microsoft.com/en-us/kb/3026376/

Upvotes: 2

Related Questions