Skip to content

QueryInterface for custom interface on untyped ComObject always returns E_NOINTERFACE #102388

Closed Answered by smourier
smourier asked this question in General
Discussion options

You must be logged in to vote

Ok , I finally got it.

Calling this:

var unk = sw.GetOrCreateComInterfaceForObject(obj, CreateComInterfaceFlags.None);

Works fine but is not what I want. I find the doc here https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.comwrappers.getorcreatecominterfaceforobject a bit ambiguous, it says:

Creates a COM representation of the supplied object that can be passed to a non-managed environment.

So what is does is "create" a Managed Object Wrapper (used to be called CCW) that here doesn't implement interfaces of course, but since the COM object is already a native object we just want it's original (or wrapped) pointer.

And this is available using the ComWrappers.…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@smourier
Comment options

@rmsimpson
Comment options

@smourier
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by smourier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants