1

How to receive strings from C# in Visual-C++ based .net DLL?

In C++ (using clr) I have this code:

#include "stdafx.h"
##include <Windows.h>
#include <string>
#include <windows.h>

namespace NSST
{
  public ref class Wrapper
  {
 public:
     Wrapper() {}
    static void init_1(std::string a, std::string b){}
     static void init_2(){}
  };
};

But in .net C# I see only one function init_2. How do I make init_1 visible in .net?

1 Answer 1

3

You can't use std::string, you should use System::String^:

static void init_1(System::String^ a, System::String^ b);
Sign up to request clarification or add additional context in comments.

3 Comments

and how to turn System::String^ a into std::string a? is it possible?
Updated link for the said article: buffered.io/posts/net-systemstring-to-ansi-char (would be great if old comments were editable too).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.