Microsoft Developer Network > Forenhomepage > Common Language Runtime > Clibpoard bug in VB 2005 or DotNetFramework 2.0
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetClibpoard bug in VB 2005 or DotNetFramework 2.0

  • Montag, 9. Januar 2006 17:03Ted Carron TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    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.

Antworten

  • Montag, 9. Januar 2006 18:09Ted Carron TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

     

    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.

     

     

Alle Antworten

  • Montag, 9. Januar 2006 18:09Ted Carron TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

     

    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.

     

     

  • Freitag, 15. September 2006 13:51Marc_1 TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    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.

  • Dienstag, 19. September 2006 00:45Obble TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Same with me.  You helped me alot there. 

    Thanks.
  • Donnerstag, 25. Januar 2007 22:02steveareno TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    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.
  • Mittwoch, 23. September 2009 19:06Stumple TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    This helped me too. I had no idea that setting would cause this.