Clibpoard bug in VB 2005 or DotNetFramework 2.0<P>I am writing code to transfer text to the clipboard in a number of formats in VB2005. I already have code which does this fine under VB.Net 2003</P> <P>Everything is fine until the&nbsp;text data which I have written onto the clipboard via a DataObject is pasted into Excel or Word,&nbsp; When you do this you get the following exception.</P> <P><FONT size=1>System.Runtime.InteropServices.COMException crossed a native/managed boundary<BR>&nbsp; Message="Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))"<BR>&nbsp; Source="mscorlib"<BR>&nbsp; ErrorCode=-2147221404<BR>&nbsp; StackTrace:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Windows.Forms.DataObject.GetDataIntoOleStructs(FORMATETC&amp; formatetc, STGMEDIUM&amp; medium)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetDataHere(FORMATETC&amp; formatetc, STGMEDIUM&amp; medium)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC&amp; formatetc, STGMEDIUM&amp; medium)</FONT></P> <P>You do not get the exception pasting into notepad</P> <P>You do not get the exception if you put the text strait onto the clipboard without a dataobject. i.e. by clipboard.SetText(...)&nbsp; This is not a solution to my problem however because I want to copy a bespoke version of the data onto the clipboard as well as the text version.</P> <P>The exception is thrown weather or not the data is represented in the data object as more than one form or not. </P> <P dir=ltr style="MARGIN-RIGHT: 0px">You can get the same exception when pasting into the same VB program if the paste is done by&nbsp;</P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P dir=ltr style="MARGIN-RIGHT: 0px">Dataobject.SetText(..)</P></BLOCKQUOTE> <P dir=ltr style="MARGIN-RIGHT: 0px">and read out of the data object by</P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P dir=ltr style="MARGIN-RIGHT: 0px">Dataobject.GetData(DataFormats.Text)</P></BLOCKQUOTE> <P>If you change the set text to </P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P>Dataobject.SetData(DataFormats.Text) </P></BLOCKQUOTE> <P>the exception disappears!</P> <P>You do not get this problem under VB.Net 2003</P> <P>I can find no reference to this problem on MSDN has anybody else encountered this problem or seen it on MSDN?</P> <P>Thanks in advance to anyone who can help.</P>© 2009 Microsoft Corporation. All rights reserved.Wed, 23 Sep 2009 19:06:16 Zcf4b8ffe-b9a5-4cbe-8fec-53328152f0a6http://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6http://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6Ted Carronhttp://social.msdn.microsoft.com/Profile/en-US/?user=Ted%20CarronClibpoard bug in VB 2005 or DotNetFramework 2.0<P>I am writing code to transfer text to the clipboard in a number of formats in VB2005. I already have code which does this fine under VB.Net 2003</P> <P>Everything is fine until the&nbsp;text data which I have written onto the clipboard via a DataObject is pasted into Excel or Word,&nbsp; When you do this you get the following exception.</P> <P><FONT size=1>System.Runtime.InteropServices.COMException crossed a native/managed boundary<BR>&nbsp; Message="Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))"<BR>&nbsp; Source="mscorlib"<BR>&nbsp; ErrorCode=-2147221404<BR>&nbsp; StackTrace:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Windows.Forms.DataObject.GetDataIntoOleStructs(FORMATETC&amp; formatetc, STGMEDIUM&amp; medium)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetDataHere(FORMATETC&amp; formatetc, STGMEDIUM&amp; medium)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC&amp; formatetc, STGMEDIUM&amp; medium)</FONT></P> <P>You do not get the exception pasting into notepad</P> <P>You do not get the exception if you put the text strait onto the clipboard without a dataobject. i.e. by clipboard.SetText(...)&nbsp; This is not a solution to my problem however because I want to copy a bespoke version of the data onto the clipboard as well as the text version.</P> <P>The exception is thrown weather or not the data is represented in the data object as more than one form or not. </P> <P dir=ltr style="MARGIN-RIGHT: 0px">You can get the same exception when pasting into the same VB program if the paste is done by&nbsp;</P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P dir=ltr style="MARGIN-RIGHT: 0px">Dataobject.SetText(..)</P></BLOCKQUOTE> <P dir=ltr style="MARGIN-RIGHT: 0px">and read out of the data object by</P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P dir=ltr style="MARGIN-RIGHT: 0px">Dataobject.GetData(DataFormats.Text)</P></BLOCKQUOTE> <P>If you change the set text to </P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P>Dataobject.SetData(DataFormats.Text) </P></BLOCKQUOTE> <P>the exception disappears!</P> <P>You do not get this problem under VB.Net 2003</P> <P>I can find no reference to this problem on MSDN has anybody else encountered this problem or seen it on MSDN?</P> <P>Thanks in advance to anyone who can help.</P>Mon, 09 Jan 2006 17:03:18 Z2006-01-12T04:41:59Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#5548743c-acd0-4399-8ba4-9d361e0f7c61http://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#5548743c-acd0-4399-8ba4-9d361e0f7c61Ted Carronhttp://social.msdn.microsoft.com/Profile/en-US/?user=Ted%20CarronClibpoard bug in VB 2005 or DotNetFramework 2.0<P>&nbsp;</P> <P>Not a bug...just a dumb programmer (me)</P> <P>I had the "Break&nbsp;when exceptions accross AppDomain..." option set in the IDE.&nbsp;</P> <P>Clearing the option solved the problem.&nbsp; </P> <P>Still not sure why this did not trigger when pasting to Notepad tho :) but I can live with my ignorance.</P> <P>Sorry if anyone spent any time looking into this.</P> <P>&nbsp;</P> <P>&nbsp;</P> <P><FONT size=2></P></FONT>Mon, 09 Jan 2006 18:09:16 Z2006-09-19T00:44:15Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#b3549dd8-cc5d-4ced-91b7-b7d7630b25c7http://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#b3549dd8-cc5d-4ced-91b7-b7d7630b25c7Marc_1http://social.msdn.microsoft.com/Profile/en-US/?user=Marc_1Clibpoard bug in VB 2005 or DotNetFramework 2.0<p>I had the same problem with dodragdrop and was getting the following error when i dragged onto the start bar:</p> <p>Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))</p> <p>Changing the &quot;Break when exceptions accross AppDomain...&quot; option set in the IDE seems to have fixed it.</p>Fri, 15 Sep 2006 13:51:01 Z2006-09-15T13:51:01Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#201683cb-b4f3-4e92-91d8-ec8463a60cb4http://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#201683cb-b4f3-4e92-91d8-ec8463a60cb4Obblehttp://social.msdn.microsoft.com/Profile/en-US/?user=ObbleClibpoard bug in VB 2005 or DotNetFramework 2.0Same with me.  You helped me alot there.  <br><br>Thanks.<br>Tue, 19 Sep 2006 00:45:09 Z2006-09-19T00:45:09Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#bd8dcdd9-8f1c-40e5-b7ac-cb3f1a140f58http://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#bd8dcdd9-8f1c-40e5-b7ac-cb3f1a140f58stevearenohttp://social.msdn.microsoft.com/Profile/en-US/?user=stevearenoClibpoard bug in VB 2005 or DotNetFramework 2.0same here.  Didn't have this issue before SP1.  not sure if applying the service pack caused this or what because I didn't set this value.Thu, 25 Jan 2007 22:02:47 Z2007-01-25T22:02:47Zhttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#2fd6deed-7968-4be0-88bb-8e422784b1cahttp://social.msdn.microsoft.com/Forums/en-US/clr/thread/cf4b8ffe-b9a5-4cbe-8fec-53328152f0a6#2fd6deed-7968-4be0-88bb-8e422784b1caStumplehttp://social.msdn.microsoft.com/Profile/en-US/?user=StumpleClibpoard bug in VB 2005 or DotNetFramework 2.0This helped me too. I had no idea that setting would cause this.Wed, 23 Sep 2009 19:06:16 Z2009-09-23T19:06:16Z