MEF 和非托管代码
有没有办法让 MEF 加载非托管代码,例如不是 Java 编写的 com 对象或本机 Win32 代码?
Is there a way of getting MEF to load unmanaged code, such as com objects that are not written Java or are native Win32 code ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以包装该类,然后导出包装器,或者您也可以创建自定义 导出提供商通过互操作甚至通过 pinvoke 的方法公开这些类型。
You could either wrap the class and then export the wrapper or you may be able to create a custom export provider that exposed these types through interop or maybe even methods through pinvoke.
您可以通过从互操作类型派生您自己的类型(这可能是更简单的解决方案),或者通过生成互操作程序集(使用 tlbimp),然后修改它以将导出属性添加到 COM 类型,从而向 COM 类型添加导出属性。班级。修改程序集需要对其进行反汇编 (ildasm)、添加对 MEF 的引用和适当类型的导出属性,然后重新组装它。
You could add an export attribute to COM types by either deriving your own type from the interop type (which is probably the simpler solution), or by generating the interop assembly (using tlbimp), and then modifying it to add an export attribute to the class. Modifying the assembly would involve disassembling it (ildasm), adding a reference to MEF and the Export attribute to the appropriate type, and then re-assembling it.