2011. 1. 3. 23:00

CustomQueryInterface - IDispatch and Aggregation

C# 에서 IDispatch 인터페이스를 직접 구현하는 방법을 찾다가 발견한 링크입니다. 비록 다른 방법을 이용하여 해결하였지만 이 방법도 혹시 나중에 유용하게 쓰일수 있지 않을까 해서 keep 해 둡니다.

Source: http://clrinterop.codeplex.com/releases/view/32350

In the CLR v4 there is a new interface called ICustomQueryInterface. This very cool new feature will enable developers to provide their own managed implementation of custom and standard COM interfaces (except IUnknown). One interesting scenario, which will be illustrated in the sample below, is dynamic managed aggregation with a flexible implementation of IDispatch

In this sample, we will show an implementation of ICustomQueryInterface through
  • a managed IDispatch implementation that overrides the default IDispatch implementation by the CLR
  • a managed COM aggregation system where both Outer and Inner objects are managed objects