动态地与 IUnknown 和 Typelib 一起工作吗
目前我正在尝试C#4的动态编程,我并不完全理解关键字dynamic在什么情况下起作用。我很清楚它可以与 IDispatch 一起使用,因为它可以自动通知调用者类型信息。但它不应该也适用于 IUnknown 和类型库吗? (在 http://samgentile.com/Web/vs2010-and-net-framework-4-0/c-4-0-bcl-4-series-dynamic-primitive-type-part-1/ 我发现一个模糊的提示,应该可以绑定到 IUnknown。)
- IUnknown w/o typelib:不应该工作,接口必须显式地用 C# 编写,所以我没有尝试。 (由 Hans Passant 在 中确认C# 4.0 动态对象和 WinAPI 接口,如 IShellItem(未在 C# 源代码中定义它们)。)
- IUnknown w/ 类型库:我完全不知道它是否工作以及如何工作工作,因为我没有找到明确的信息。 (我将类型库链接到 COM dll 中,但 DLR 无法绑定方法。)
那么带类型库的 IUnknown 是否可以与 C# 的动态关键字一起使用? - 如果是这样,我该怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我目前的发现是 COM-binder 只能与 IDispatch 一起使用,而根本不能与 IUnknown 一起使用。
My current foundings are that the COM-binder only works with IDispatch and not with IUnknown at all.