是否可以导出 C++带有 MEF 和 Prism 的 CLI 界面
我有一个在 C++ 库中定义的 C++/CLI 接口(使用 /clr 开关编译) 我还有一个 C# 库。
我的 C# 库定义: - 实现 Prism IModule 的类界面。 - 实现 C++/CLI 接口并用 MEF 修饰的类导出属性。
C# 和 C++\CLI 库都部署到同一文件夹中。
我从 Prism 收到 ModuleLoadException,表示它找不到我的 C++/CLI 程序集或其依赖项之一。
如果我用 .NET 程序集替换 C++/CLI 程序集,一切都会正常!
那么我的问题是,是否可以导出一个实现 C++\CLI 接口的类,并且导出类型是该接口?
为什么我要在 C++/CLI 库中定义接口?我希望我们拥有的遗留 C++ DLL 实际上可以在 C++\CLI 库中定义它们的合约,并让 C# 库引用该合约 dll。 也许我的方法是错误的,如果您认为有更好的方法来实现这一点,请告诉我。
I have a C++/CLI interface defined in a C++ library (Compiled with the /clr switch)
I also have a C# library.
My C# library defines:
- a class that implements Prism IModule interface.
- a class that implements the C++/CLI interface and is decorated with MEF Export attribute.
both the C# and the C++\CLI library are deployed into the same folder.
I am getting a ModuleLoadException from Prism saying that it can't find my C++/CLI assembly or one of its dependencies.
If I replace the C++/CLI assembly with a .NET one, everything works fine!
My question is then , is it at all possible to export a class that implements a C++\CLI interface with the export type being that interface?
Why do I have the interface defined in a C++/CLI library? I was hoping that a legacy C++ DLL we have could actually define their contracts in that C++\CLI libraries and have C# libraries reference that contract dll.
Maybe my approach is wrong, please let me know if you think there is a better way to achieve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前并没有花太多时间使用 C++/CLI,但由于它是一种符合 CLS 的语言,因此它应该可以正常工作。下面是一个示例
在我的 C# 控制台应用程序中:
部署 C++/CLI 程序集应该没有特殊要求,因为无论如何部署时都是一样的。您能否检查您的 C++/CLI 程序集是否也部署了任何依赖项?
I haven't really spent much time with C++/CLI before, but as it's a CLS-compliant language, it should just work. Here is an example
And in my C# console app:
There should be no special requirements for deploying C++/CLI assemblies, as it's all the same at deployment anyways. Can you check that any dependencies are deployed with your C++/CLI assembly too?