2011-05-09 49 views
0

重现步骤:AllowsTransparency属性将导致未处理的异常

  1. 创建新的WPF项目
  2. 在系统日志

在设置AllowsTransparency="True"Window

  • 运行
  • 看我的在Windows 7个人电脑上我有日志:

    Application: WpfApplication1.exe 
    Framework Version: v4.0.30319 
    Description: The process was terminated due to an unhandled exception. 
    Exception Info: System.InvalidOperationException 
    Stack: 
        at System.Windows.Window.VerifyConsistencyWithAllowsTransparency(System.Windows.WindowStyle) 
        at System.Windows.Window.CoerceVisibility(System.Windows.DependencyObject, System.Object) 
        at System.Windows.DependencyObject.ProcessCoerceValue(System.Windows.DependencyProperty, System.Windows.PropertyMetadata, System.Windows.EntryIndex ByRef, Int32 ByRef, System.Windows.EffectiveValueEntry ByRef, System.Windows.EffectiveValueEntry ByRef, System.Object ByRef, System.Object, System.Object, System.Windows.CoerceValueCallback, Boolean, Boolean, Boolean) 
        at System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex, System.Windows.DependencyProperty, System.Windows.PropertyMetadata, System.Windows.EffectiveValueEntry, System.Windows.EffectiveValueEntry ByRef, Boolean, Boolean, System.Windows.OperationType) 
        at System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty, System.Object, System.Windows.PropertyMetadata, Boolean, Boolean, System.Windows.OperationType, Boolean) 
        at System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty, System.Object) 
        at System.Windows.UIElement.set_Visibility(System.Windows.Visibility) 
        at System.Windows.Application.ConfigAppWindowAndRootElement(System.Object, System.Uri) 
        at System.Windows.Application.DoStartup() 
        at System.Windows.Application.<.ctor>b__1(System.Object) 
        at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 
        at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) 
        at System.Windows.Threading.DispatcherOperation.InvokeImpl() 
        at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) 
        at System.Threading.ExecutionContext.runTryCode(System.Object) 
        at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) 
        at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
        at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
        at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
        at System.Windows.Threading.DispatcherOperation.Invoke() 
        at System.Windows.Threading.Dispatcher.ProcessQueue() 
        at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) 
        at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) 
        at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) 
        at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 
        at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) 
        at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) 
        at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) 
        at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) 
        at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 
        at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 
        at System.Windows.Threading.Dispatcher.Run() 
        at System.Windows.Application.RunDispatcher(System.Object) 
        at System.Windows.Application.RunInternal(System.Windows.Window) 
        at System.Windows.Application.Run(System.Windows.Window) 
        at System.Windows.Application.Run() 
        at WpfApplication1.App.Main() 
    

    任何人都可以确认吗?

    我使用的软件:VS 2010 Express(SP1),Windows 7家庭高级版。

  • +0

    你确定这不是为MSDN的错误报告? :) – BoltClock 2011-05-09 05:03:17

    +0

    @BoltClock:我需要检查它是否不是我的本地问题或最初缺乏一些秘密知识;-) – zerkms 2011-05-09 05:04:17

    +0

    我们有几乎相同的规格,我尝试与您的步骤,我有同样的错误,你有过。 [VS 2010 Ultimate(SP1)Win 7 Ultimate] – 2011-05-09 05:16:03

    回答

    5

    只是改变

    WindowStyle =“无”

    +0

    +1在未来,OP应该在调试器下运行它并在屏幕上阅读消息。 :-) – 2011-05-09 05:17:00

    +0

    因此,预计更改一个窗口属性没有另一个会导致异常?! – zerkms 2011-05-09 05:18:01

    +0

    @Rick Sladkey:Omg,感觉很虚拟:-S – zerkms 2011-05-09 05:18:46

    相关问题