开发者

How to Inherit C++/CLI Interface in C#?

I have declared an interface in C++/CLI and made it an assembly(DLL). I want that interface to be implement by a C# app. I have added the reference but my C# assembly does not detecting my C++/CLI interface and says "Could not find: You ar开发者_JAVA技巧e missing some assembly refernce."

How can I resolve this?


Make sure that your dll support CLR. (Tab General in Configuration Properties in Visual Studio).


Knowing this is an old question, but I had the same issue. Additionally, your c++/cli needs to provide some source (cpp) code (which is actually nearly empty):

IXYprovider.h:

namespace Interfaces { public interface class IXYprovider { ... } }

IXYProvider.cpp:

#include "IXYprovider.h" namespace Interfaces { }

That makes it visible to C#.


Make sure that the interface class is declared public in the C++/CLI assembly. I recommend the free version of Red Gate .NET Reflector for viewing visibility of types in a compiled assembly.


Is the interface defined within a namespace within the C++/CLI assembly? If so have you put 'using [namespace]' at the top of your C# file?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜