dimanche 8 mars 2015

Property of interface implemented by c# class not accessible from c++/cli


Vote count:

0




I'm trying to implement a native interface to a class developed in c#, using VS2013. Here's a simplified version of it:



namespace ManagedTypes
{
public static class CaptureFile
{
public static IPacketList GetPackets() { new PacketList(); }
}
}


Here's the definition of the IPacketList interface:



namespace ManagedTypes
{
public interface IPacketList: IReadOnlyList<IPacket>
{
}
}


Just to be thorough, IReadOnlyList<T> (in mscorlib) is declared as:



public interface IReadOnlyList<out T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
{
T this[int index] { get; }
}


and IReadOnlyCollection<T> (also is mscrolib) as



public interface IReadOnlyCollection<out T> : IEnumerable<T>, IEnumerable
{
int Count { get; }
}


So, from C#, I can do something like:



var n = CaptureFile.GetPackets().Count;


But if I try to do something similar from C++:



auto n = CaptureFile::GetPackets()->Count;


I get the following compilation error:



Error 2 error C2039: 'Count' : is not a member of 'ManagedTypes::IPacketList' C:\Hg\DP1000-DEV\src\Spikes\MixedModeSample\MixedMode\MixedModeApi.cpp 9 1 MixedMode


What am I missing here?



asked 15 secs ago







Property of interface implemented by c# class not accessible from c++/cli

Aucun commentaire:

Enregistrer un commentaire