Article ID: 152072 - Last Review: December 1, 2003 - Revision: 2.0 FIX: ASSERT in OLECLI1.CPP When Copying Embedding to ClipboardThis article was previously published under Q152072 On This PageSYMPTOMS
When you attempt to copy an embedding in an in-place active object to the
clipboard, the result is an ASSERT in OLECLI1.CPP. Specifically, the ASSERT
occurs in the COleClientItem::XOleClientSite::GetMoniker() function on the
following line of code:
CAUSE
When you copy an embedding to the clipboard, a number of data formats are
placed on the clipboard, including link source information. The link source
information contains a moniker used to locate the document in which the
embedding resides.
When the container assigns a moniker to an embedded object, it will call the object's IOleObject::SetMoniker() function. The object will then call the container's IOleClientSite::GetMoniker() function to construct a composite moniker based on the container's moniker. This is done because the container may have changed its moniker while the object was not running. When the embedded object calls IOleClientSite::GetMoniker() to get the container's moniker, COleClientItem::XOleClientSite::GetMoniker() ASSERTs on the aforementioned line of code because pThis->m_bMoniker had not been set to TRUE when the moniker was assigned during a previous call to COleClientItem::XOleClientSite::GetMoniker(). The problem is located in the following section of the COleClientItem::XOleClientSite::GetMoniker() function located in OLECLI1.CPP: RESOLUTION
To work around this problem, you must override the default IOleClientSite
interface implementation in COleClientItem. This can be done by adding an
interface map to the class in your project that is derived from
COleClientItem and setting pThis->m_bMoniker to TRUE before calling pThis-
>m_lpObject->SetMoniker() from your custom GetMoniker() function.
The code below illustrates how to override the COleClientItem-derived object using the OCLIENT MFC sample application. STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug was corrected in Visual C++ 32-
bit Edtion version 4.2.
MORE INFORMATIONSample CodeAPPLIES TO
| Article Translations
|

Back to the top
