Clipboard behaves differently in .NET 3.5 and 4.5.2

0

We have upgraded our application from .NET 2.0 to 4.5.2 and using VS2013.

We are facing one issue with Clipboard, everything was working fine with 2.0 in WIN8 also. Now with 4.5.2 clipboard ONLY works fine in WIN7 not in WIN8.1

Our code is as below.

DataObject dataObject = new DataObject();
IDataObject iObj = Clipboard.GetDataObject() as DataObject;
string[] formats = iObj.GetFormats();
for (int i = 0; i < formats.Length; i++)
{
     object obj = iObj.GetData(formats[i]);
     if (obj != null)
     {
           dataObject.SetData(formats[i], obj);
     }

}
//add rtf

dataObject.SetData(DataFormats.Rtf, rtfText.rtf_text);

if (rtfText.rtf_text.IndexOf("Symbol") < 0)
 {
      //add simple text
   using (RichTextBox rtb = new RichTextBox())
   {
     rtb.Rtf = rtfText.rtf_text; 
     dataObject.SetData(DataFormats.Text, rtb.Text);
 }
 }
Clipboard.SetDataObject(dataObject, true); //CRASHING HERE

I think the issue is with adding the RTF object. without this RTF data its working fine.

Getting error: invalid tymed exception from hresult: 0x80040069 Saw this in stack overflow, but dont know how to proceed in my case - Clipboard behaves differently in .NET 3.5 and 4, but why?

Thanks in advance, Please help.

Regards

Biju Koshy

c#
visual-studio-2013
asked on Stack Overflow Feb 26, 2016 by user3616017 • edited May 23, 2017 by Community

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0