How do I pass a vector of strings from managed(C#) code to native(C++) DLL?

If you have the following c++ method, how can you create a C++ std::vector<std::string> object and pass it to C++ native DLL using the C# wrapper library for C++ run-time?

To call the native method, let’s define the P/Invoke signature first.

And then, you can instantiate an object of StdStringVector, populate the content and pass the object to the native method. You have successfully passed a std::vector<std::string> object from C# to native C++ DLL.

← Faqs
Translate »