Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer the question the reason it is failing is that the innerUnknown is the wrong unknown. The method is intended to get the active RCW for a COM IUnknown, but this IUnknown is a Com-callable wrapper for a Managed object. </p> <p>In any case, the outer object needs the <code>innerUnknown</code> pointer. If you gave it the one you are trying to you would get a stack overflow in QueryInterface.</p> <p>In your example above, the .Net object thinks it has been aggregated by the COM object, but the COM object isn't aware. Assuming it is your COM object, you need to give it innerUnknown, and then implement a delegating IUnknown (if you haven't already). You don't need to call GetObjectForIUnknown.</p> <p>You are kind of doing it backwards however. The usual way is for the COM object to call CoCreateInstance passing itself as the outer unknown. The runtime then calls CreateAggregatedObject for you.</p> <hr> <p>If you want the .Net object to aggregate the COM object, you should inherit from the RCW. This will create the COM object as an aggregated object passing your .Net inner unknown to CoCreateInstance. But it has to be an object which supports aggregation.</p> <p>If you want the COM object to aggregate the .Net object, you have to use a COM object which does that. Typical examples are ADO aggregating OLEDB providers, ADSI aggregating ADSI extensions, WMI (I think). But it has to be supported by the object, you can't tell any old object to aggregate you. Usually it occurs by the other object calling CoCreateInstance, which is handled by the .Net runtime, which will call CreateAggregatedObject for you, and pass the innerUnknown back to the caller.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload