MartyIX
MartyIX

Reputation: 28648

How to marshall data type unsigned char** in C#?

I'm trying to marshall unsigned char** (which is in a C++ interface) in order to call the method from C#.

How can this be done? Is there a list where are C++ data types and C# data types?

Thanks!

Upvotes: 2

Views: 2187

Answers (3)

the_void
the_void

Reputation: 5538

I think you should use a serialization library that has an interface for both C++ and C#.

Both Protocol Buffers from Google or Thrift from Facebook support these two languages.

It would definitely make things much easier and safer for you.

If you decide to change the transferred data types (i.e. use integers, structures, etc. instead of raw strings), using a serialization library is the way to go.

Upvotes: 1

codymanix
codymanix

Reputation: 29468

What is the semantics of this unsigned char**? If it is a byte array, use ref byte[]. If it is a zero terminated string, use ref string.

You can find some popular method signatures mapped to c# on the page http://www.pinvoke.net, which may give you the idea.

Upvotes: 2

ErikHeemskerk
ErikHeemskerk

Reputation: 1701

That would be marshalable as ref string. Be sure to use the right character set with a [MarshalAs] attribute.

Upvotes: 0

Related Questions