登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

秒大刀 博客

好好学习 天天向上

 
 
 

日志

 
 
 
 

不稳定的剪切板  

2007-11-14 18:51:54|  分类: C# |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

        频繁的剪切板操作,或者在系统繁忙的时候(尤其是UI繁忙时),会有小概率报错。经查证这个是属于OS级的bug !? 不稳定的剪切板 - 秒大刀 - 秒大刀 博客  在一个不稳定的系统上,再加上一层不稳定的虚拟机,然后再去整一滩不稳定的软件体系,居然能拥有绝大多数的用户市场。微软无敌不稳定的剪切板 - 秒大刀 - 秒大刀 博客

[OS] Windows XP SP2

[Framework] 2.0

[Exception]  所请求的剪贴板操作失败。

[Message]    System.Runtime.InteropServices.ExternalException

[StackTrace]    在 System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)

   在 System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy, Int32 retryTimes, Int32 retryDelay)

   在 System.Windows.Forms.Clipboard.SetText(String text, TextDataFormat format)

   在 System.Windows.Forms.Clipboard.SetText(String text)

   在 Test.ToolStripMenuItem_Click(Object sender, EventArgs e)

   在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

   在 System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)

   在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

   在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

   在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)

   在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)

   在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

   在 System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)

   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

   在 System.Windows.Forms.Control.WndProc(Message& m)

   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)

   在 System.Windows.Forms.ToolStrip.WndProc(Message& m)

   在 System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)

   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


2012-12-6
又发现一种剪切板错误:
[OS] Windows7 SP1
[Framework] 3.5
[Exception]  OpenClipboard 失败 (异常来自 HRESULT:0x800401D0 (CLIPBRD_E_CANT_OPEN))
[Message]    System.Runtime.InteropServices.COMException
[StackTrace]    在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   在 System.Windows.Clipboard.Flush()
   在 System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   在 System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
   在 System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   在 System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   在 System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   在 System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
   在 System.Windows.Input.CommandManager.TransferEvent(IInputElement newSource, ExecutedRoutedEventArgs e)
   在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   在 System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
   在 System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   在 System.Windows.Threading.DispatcherOperation.InvokeImpl()
   在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Windows.Threading.DispatcherOperation.Invoke()
   在 System.Windows.Threading.Dispatcher.ProcessQueue()
   在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   在 MyProgram.Program.Main() 位置 E:\trunk\Tools\MyProgram\Program.cs:行号 33

解决方案:
    参考CLIPBRD_E_CANT_OPEN error when setting the Clipboard from .NET中的循环等待尝试方法是一种有效的解决方案。
    另外本应用中,我是将WPF窗体嵌入了WinForm的应用中,而WPF中调用的Clipboard应该是System.Windows.Clipboard,而不是System.Windows.Form.Clipboard,不排除与此相关。
  评论这张
 
阅读(3973)| 评论(11)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018