C# WPF应用程序崩溃,出现“故障”;类型为';的未处理异常;System.ComponentModel.Win32Exception';发生在WindowsBase.dll中;

C# WPF应用程序崩溃,出现“故障”;类型为';的未处理异常;System.ComponentModel.Win32Exception';发生在WindowsBase.dll中;,c#,.net,windows,exception,C#,.net,Windows,Exception,我正在开发一个使用.NET3.5的应用程序,该应用程序是32位的,在64位Windows7上使用 调用showDialog()时应用程序崩溃,下面是代码段和 引发异常 例外情况: WindowsBase.dll中发生“System.ComponentModel.Win32Exception”类型的未处理异常 其他信息:没有足够的配额可用于处理此问题 命令 代码段: try { WindowInteropHelper l_WndInteropHel

我正在开发一个使用.NET3.5的应用程序,该应用程序是32位的,在64位Windows7上使用

调用showDialog()时应用程序崩溃,下面是代码段和 引发异常

例外情况:

WindowsBase.dll中发生“System.ComponentModel.Win32Exception”类型的未处理异常

其他信息:没有足够的配额可用于处理此问题 命令

代码段:

     try
        {
            WindowInteropHelper l_WndInteropHelper = new WindowInteropHelper(this);
            l_WndInteropHelper.Owner = f_pParentWnd;
            this.f_pParentWnd = f_pParentWnd;
            m_bWndDisplayed = true;

            this.ShowDialog();
            //reset to false as window will be closed by this time.
            m_bWndDisplayed = false;
        }
        catch (Exception ex)
        {}
当我使用同一应用程序的64位版本时,问题不会重现

以下是在
showDialog()
和异常之间生成的调用堆栈

->WindowsBase.dll!MS.Win32.UnsafeNativeMethods.PostMessage(System.Runtime.InteropServices.HandleRef hwnd, int msg, System.IntPtr wparam, System.IntPtr lparam) + 0x3d bytes 
->PresentationCore.dll!System.Windows.Interop.HwndTarget.UpdateWindowSettings(bool enableRenderTarget, System.Windows.Media.Composition.DUCE.ChannelSet? channelSet) + 0x3ce bytes  
->PresentationCore.dll!System.Windows.Interop.HwndTarget.UpdateWindowSettings(bool enableRenderTarget) + 0x2f bytes 
->PresentationCore.dll!System.Windows.Interop.HwndTarget.UpdateWindowPos(System.IntPtr lParam) + 0x185 bytes    
->PresentationCore.dll!System.Windows.Interop.HwndTarget.HandleMessage(int msg, System.IntPtr wparam, System.IntPtr lparam) + 0xff bytes    
->PresentationCore.dll!System.Windows.Interop.HwndSource.HwndTargetFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x3a bytes    
->WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0xbe bytes  
->WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x7a bytes  
->WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, bool isSingleParameter) + 0x8a bytes    
->WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler) + 0x4a bytes   
->WindowsBase.dll!System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler) + 0x44 bytes   
->WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, bool isSingleParameter) + 0x91 bytes   
->WindowsBase.dll!System.Windows.Threading.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority priority, System.Delegate method, object arg) + 0x40 bytes 
->WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) + 0xdc bytes   
->[Native to Managed Transition]    
->user32.dll!74c362fa()
->[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]  
->user32.dll!74c37316()
->user32.dll!74c36ce9()
->user32.dll!74c36de8()
->user32.dll!74c38f09()
->ntdll.dll!76f1010a()
->user32.dll!74c38e63()
->[Managed to Native Transition]    
->PresentationFramework.dll!System.Windows.Window.SetupInitialState(double requestedTop, double requestedLeft, double requestedWidth, double requestedHeight) + 0x5a7 bytes 
->PresentationFramework.dll!System.Windows.Window.CreateSourceWindowImpl() + 0x19b bytes    
->PresentationFramework.dll!System.Windows.Window.SafeCreateWindow() + 0x29 bytes   
->PresentationFramework.dll!System.Windows.Window.ShowHelper(object booleanBox) + 0x81 bytes    
->PresentationFramework.dll!System.Windows.Window.Show() + 0x48 bytes   
->PresentationFramework.dll!System.Windows.Window.ShowDialog() + 0x29f bytes

看起来您正在尝试pinvoke以确定窗口所有者?与其这样做,只需将“this”上的Owner设置为您希望成为父对象的另一个“Window”类型的对象

this.Owner=myParentWindow