Clipboard =(
От: Pavel M. Россия  
Дата: 13.12.06 14:15
Оценка:
                String clipboardData = (String)Clipboard.GetData(DataFormats.StringFormat);
                if (clipboardData != null)
                    if (Clipboard.ContainsText(TextDataFormat.UnicodeText))
                    {
                        Clipboard.Clear();
                        Clipboard.SetText(signer.SignXml(clipboardData).ToString()); Тут вылетает ExternalException
                    }


в указанном месте не всегда, но часто вылетае ExternalException, ошибка при работе с буфером обмена, вроде, пишется. на текстовых данных. почему, я не понимаю. кто может подсказать?
--------------------------
less think — do more
Re: Clipboard =(
От: Pavel M. Россия  
Дата: 13.12.06 14:34
Оценка:
Здравствуйте, Pavel M., Вы писали:

   в 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)
   в ClientKeysManager.MainForm.signDataToolStripMenuItem_Click(Object sender, EventArgs e) в D:\SourceSafeProjects\RemoteServer\ClientKeysManager\MainForm.cs:строка 123
   в 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.DebuggableCallback(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(Int32 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)
   в System.Windows.Forms.Application.Run(Form mainForm)
   в ClientKeysManager.Program.Main() в D:\SourceSafeProjects\RemoteServer\ClientKeysManager\Program.cs:строка 17
   в System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
   в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   в System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   в System.Threading.ThreadHelper.ThreadStart()


Код изменил на такой

                if (Clipboard.ContainsText())
                {
                    String clipboardData = Clipboard.GetText();
                    Clipboard.Clear();
                    Clipboard.SetText(signer.SignXml(clipboardData).ToString());
                }


Никто не сталкивался что ли с таким???
--------------------------
less think — do more
Re[2]: Clipboard =(
От: Pavel M. Россия  
Дата: 13.12.06 14:41
Оценка:
PM>Никто не сталкивался что ли с таким???

Читаем МСДН

ExternalException
 The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process.

прикольно, как бороться?
--------------------------
less think — do more
Re[3]: Clipboard =(
От: Pavel M. Россия  
Дата: 13.12.06 15:08
Оценка:
Здравствуйте, Pavel M., Вы писали:

PM>>Никто не сталкивался что ли с таким???


PM>Читаем МСДН


PM>
PM>ExternalException
PM> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process.
 
PM>

PM>прикольно, как бороться?


                if (Clipboard.ContainsText())
                {                    
                    String clipboardData = Clipboard.GetText();
                    Clipboard.SetDataObject(signer.SignXml(clipboardData), false, 100, 10);
                }


сделал так и забил
--------------------------
less think — do more
Re[3]: Clipboard =(
От: eugene__ Украина  
Дата: 03.03.07 16:19
Оценка:
Здравствуйте, Pavel M., Вы писали:

PM>>Никто не сталкивался что ли с таким???


PM>Читаем МСДН


PM>
PM>ExternalException
PM> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process.
 
PM>

PM>прикольно, как бороться?

может Exception из-за этого...

(из MSDN)
The Clipboard class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.