MSDN > 論壇首頁 > Common Language Runtime > Clibpoard bug in VB 2005 or DotNetFramework 2.0
發問發問
 

已答覆Clibpoard bug in VB 2005 or DotNetFramework 2.0

  • 2006年1月9日 下午 05:03Ted Carron 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    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

    Everything is fine until the text data which I have written onto the clipboard via a DataObject is pasted into Excel or Word,  When you do this you get the following exception.

    System.Runtime.InteropServices.COMException crossed a native/managed boundary
      Message="Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))"
      Source="mscorlib"
      ErrorCode=-2147221404
      StackTrace:
           at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
           at System.Windows.Forms.DataObject.GetDataIntoOleStructs(FORMATETC& formatetc, STGMEDIUM& medium)
           at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetDataHere(FORMATETC& formatetc, STGMEDIUM& medium)
           at System.Windows.Forms.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC& formatetc, STGMEDIUM& medium)

    You do not get the exception pasting into notepad

    You do not get the exception if you put the text strait onto the clipboard without a dataobject. i.e. by clipboard.SetText(...)  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.

    The exception is thrown weather or not the data is represented in the data object as more than one form or not.

    You can get the same exception when pasting into the same VB program if the paste is done by 

    Dataobject.SetText(..)

    and read out of the data object by

    Dataobject.GetData(DataFormats.Text)

    If you change the set text to

    Dataobject.SetData(DataFormats.Text)

    the exception disappears!

    You do not get this problem under VB.Net 2003

    I can find no reference to this problem on MSDN has anybody else encountered this problem or seen it on MSDN?

    Thanks in advance to anyone who can help.

解答

  • 2006年1月9日 下午 06:09Ted Carron 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆

     

    Not a bug...just a dumb programmer (me)

    I had the "Break when exceptions accross AppDomain..." option set in the IDE. 

    Clearing the option solved the problem. 

    Still not sure why this did not trigger when pasting to Notepad tho :) but I can live with my ignorance.

    Sorry if anyone spent any time looking into this.

     

     

所有回覆

  • 2006年1月9日 下午 06:09Ted Carron 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆

     

    Not a bug...just a dumb programmer (me)

    I had the "Break when exceptions accross AppDomain..." option set in the IDE. 

    Clearing the option solved the problem. 

    Still not sure why this did not trigger when pasting to Notepad tho :) but I can live with my ignorance.

    Sorry if anyone spent any time looking into this.

     

     

  • 2006年9月15日 下午 01:51Marc_1 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    I had the same problem with dodragdrop and was getting the following error when i dragged onto the start bar:

    Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))

    Changing the "Break when exceptions accross AppDomain..." option set in the IDE seems to have fixed it.

  • 2006年9月19日 上午 12:45Obble 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Same with me.  You helped me alot there. 

    Thanks.
  • 2007年1月25日 下午 10:02steveareno 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    same 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.
  • 2009年9月23日 下午 07:06Stumple 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    This helped me too. I had no idea that setting would cause this.