0

I'm trying to write a wrapper dll in C++/CLI to use some native classes in c#.

For Testing I created another C++/CLI Project that consumes the dll.

My Problem is, that I would like to use one of the native classes in the dll project in the test project, but the linker complains that it does not find the symbols for this class members. I guess it's because the native class is not defined ref public. As the native class code is auto generated by the Google Protobuffers compiler I can not add ref public to it.

Don't misunderstand me, I don't want to use this native class in the future c# project but I want to directly access it in the Test project.

MaksymB
  • 1,267
  • 10
  • 33
Thomas
  • 8,397
  • 7
  • 29
  • 39
  • Why don't you use protobuf-net? – svick Jun 28 '12 at 10:21
  • Because the lower layer should stay as much as possible c++ – Thomas Jun 28 '12 at 10:30
  • And why is that? Do you have any actual reasons for that? – svick Jun 28 '12 at 10:33
  • The same dll also wrapps needs to call functions of another native c dll. So I would have to marshall databuffers from the c dll to managed c++/c# and then use protobuf-net. Also it's not impossible that parts of the code could be integrated into pure c++ enviroments. And least, I looked at both .net protobuf imlementations and did not really like the interfaces. If it's not possible, I will abandon die idea with the Test project accessing the native class and provide a pure managed test interface from the dll. – Thomas Jun 28 '12 at 10:39
  • I just rechecked the protobuf-net API and the mein problem is, that it does not use the standard .proto Files. As we have to share one Protobuff definition between different platforms, this is no alternative. – Thomas Jun 29 '12 at 06:15

1 Answers1

0

I think you have to follow the typical native c++ way of doing this: export the class from the dll, link against the dll from the test project, and then #include the header file from the test project where you need to use the class.

I don't think there is a "managed way" to reference and use a native class (hopefully others will correct me if I'm wrong).

Matt Smith
  • 17,026
  • 7
  • 53
  • 103
  • I guess you are right. As I only need it for testing purpose it would be to much of a hassle. So I will add a managed Testing Class to the dll. – Thomas Jun 29 '12 at 06:16