Wrapping a COM object/dynamic type in C#

笑着哭i 提交于 2019-12-02 03:55:54

The opensource framework Impromptu-Interface will wrap a dynamic object with a static interface such that all the statically defined members from the interface use the dlr to forward to the dynamic object.

Create Your interface

IComObjectWrapper
{
   void SomeMethod(int x);
   bool SomeProp;
}

Then where you need to wrap your com object include ImpromptuInterface

  using ImpromptuInterface;

And finally to wrap it:

var tStaticTyped = Impromptu.ActLike<IComObjectWrapper>(comObject);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!