【问题标题】:AllowsTransparency property causes unhandled exceptionAllowsTransparency 属性导致未处理的异常
【发布时间】:2011-05-09 05:00:45
【问题描述】:

重现步骤:

  1. 创建新的 WPF 项目
  2. AllowsTransparency="True" 设置为Window
  3. 运行
  4. 查看系统日志

在我的两台 Windows 7 PC 上,我都有日志:

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 家庭高级版。

【问题讨论】:

  • 你确定这不是 MSDN 的错误报告吗? :)
  • @BoltClock: 我需要先检查一下是不是我的本地问题或缺乏一些秘密知识;-)
  • 我们的规格几乎相同,我按照您的步骤进行尝试,我遇到了与您相同的错误。 [VS 2010 Ultimate (SP1) Win 7 Ultimate]

标签: .net wpf exception


【解决方案1】:

只是改变

WindowStyle="无"

【讨论】:

  • +1 将来,OP 应该只在调试器下运行它并阅读屏幕上的消息。 :-)
  • 所以预计一个窗口属性的改变而没有另一个会导致异常?!
  • @Rick Sladkey:天啊,感觉好傻:-S
  • @zerkms:这就是文档所说的:msdn.microsoft.com/en-us/library/…
  • @zerkms:异常消息,信息,不在系统日志中,这不是令人沮丧吗...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多