Q:

MFC Drag into C# Drop

I Have a ProjectA(MFC Dlg) include the usercontrol(Chart c#)
When i drag the item(CTreectrl) from MFC Dlg to the C# chart .
For example :
http://i.stack.imgur.com/wkatk.png
And the C# m_chartGantt_DragOver will be called. but crash 
"Debug Assertion failed! ... cmdtarg.cpp 43"
private void m_chartGantt_DragOver(object sender, DragEventArgs e)
private void m_chartGantt_DragDrop(object sender, DragEventArgs e)

I don't know how to fix it ? or it can't work actually? 
Any comments will be much appreciated.
And here is MFC Code.
void CDropButton::OnLButtonDown( UINT nFlags, CPoint point ){
  COleDataSource *pDataSource = new COleDataSource();
  if (DoCopyData(pDataSource))
  {
      pDataSource->DoDragDrop(DROPEFFECT_COPY);
  }
  if (pDataSource)
  {
      delete pDataSource;   **// error here!!**
  }
}

BOOL CDropTreeCtrl::DoCopyData(COleDataSource *pDataSource)
{ 
    char  szText[] = _T("Here is some sample text that was copied using a COleDataSource object!");

    HGLOBAL hMem = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, ::lstrlen (szText) +1);
    if (hMem != NULL)
    {
        LPSTR pData = (LPSTR) ::GlobalLock(hMem);
        ::lstrcpy (pData, szText);
        pDataSource->CacheGlobalData(CF_UNICODETEXT, hMem);
        return TRUE;
    }

    return FALSE;
}

EDIT
If it helps, this section of code covers line 43 of cmdtarg.cpp:
CCmdTarget::~CCmdTarget()
{
#ifndef _AFX_NO_OLE_SUPPORT
    if (m_xDispatch.m_vtbl != 0)
        ((COleDispatchImpl*)&m_xDispatch)->Disconnect();
    ASSERT(m_dwRef <= 1);
#endif
    m_pModuleState = NULL;
}

A:

You don't have to delete the pDataSource after you have called DoDragDrop.
It is a COM object and its lifetime is only controlled by COM. 
The ASSERT tells you that somebody tries to delete the object while it is in use. Verify it and look into the callstack. It is your delete!

