0

I have written a C++/CLI library that exports a class with two generic functions:

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);

};

The dll compiles fine. When I try to use this functions in my C# project I get the error:

WavelabsLightsourceSystem.TargetInterface.ReadProtobufMessage<T>(T)' is inaccessible due to its protection level

Here is the c# part where I try to use the Funktions:

       pb_MessageHeader header = new pb_MessageHeader();
       TargetInterface target = new TargetInterface();

       target.ReadProtobufMessage<pb_MessageHeader>(header);
Thomas
  • 8,397
  • 7
  • 29
  • 39

2 Answers2

1

As per Hans Passants comment I had to make the CommunicationState enum public.

Thanks Hans, your Crystall ball was correct. I didn't dream of, that I have to make an enum public.

Justin
  • 84,773
  • 49
  • 224
  • 367
Thomas
  • 8,397
  • 7
  • 29
  • 39
0

I ran into the same exact issue, but my problem was actually due to different .NET Frameworks being targeted in different projects, as detailed here:

Why do I get a warning icon when I add a reference to an MEF plugin project?

Community
  • 1
  • 1
NielW
  • 3,626
  • 1
  • 30
  • 38