Microsoft Developer Network > 포럼 홈 > Common Language Runtime > Clibpoard bug in VB 2005 or DotNetFramework 2.0
질문하기질문하기
 

답변됨Clibpoard bug in VB 2005 or DotNetFramework 2.0

  • 2006년 1월 9일 월요일 오후 5: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일 월요일 오후 6: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일 월요일 오후 6: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일 금요일 오후 1: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일 수요일 오후 7:06Stumple 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    This helped me too. I had no idea that setting would cause this.