Does dynamic work with IUnknown and Typelib
-
05-02-2021 - |
Pregunta
Currently I'm experimenting with C#4's dynamic programming and I did not completely understand under which circumstances the keyword dynamic works. It is clear to me that it works with IDispatch, as it allows to inform the caller with type information automatically. But shouldn't it also work with IUnknown and a type lib? (In http://samgentile.com/Web/vs2010-and-net-framework-4-0/c-4-0-bcl-4-series-dynamic-primitive-type-part-1/ I found a vague hint that a Binding to IUnknown should be possible.)
- IUnknown w/o typelib: should not work, the interfaces must be written in C# explicitly, so I didn't try it. (Confirmed by Hans Passant in C# 4.0 dynamic object and WinAPI interfaces like IShellItem (without defining them in the C# source).)
- IUnknown w/ type lib: I have completely no idea, if it works and how it works as I found no clear information. (I linked the type lib into the COM dll, but the DLR could not bind methods.)
So does IUnknown w/ type lib work with C#'s dynamic keyword? - If so, what do I have to do?
Solución
My current foundings are that the COM-binder only works with IDispatch and not with IUnknown at all.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow