我编写了一个 C++/CLI 库,它导出一个具有两个通用函数的类:
public ref class TargetInterface
{
public:
static uint32_t buffer_length = 4096;
TargetInterface();
static bool Connect(char* deviceAdress);
static void Disconnect(char* deviceAdress);
generic<typename T>CommunicationState WriteProtobufMessage( T object);
generic<typename T>CommunicationState ReadProtobufMessage([Out] T object);
};
dll编译良好。当我尝试在我的 C# 项目中使用此函数时,我收到错误:
WavelabsLightsourceSystem.TargetInterface.ReadProtobufMessage<T>(T)' is inaccessible due to its protection level
这是我尝试使用 Funktions 的 c# 部分:
pb_MessageHeader header = new pb_MessageHeader();
TargetInterface target = new TargetInterface();
target.ReadProtobufMessage<pb_MessageHeader>(header);