views:

40

answers:

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?

+3  A: 

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

static void init_1(System::String^ a, System::String^ b);
OJ
and how to turn System::String^ a into std::string a? is it possible?
Blender
Sure, take a look here: http://buffered.io/2007/03/02/net-systemstring-to-ansi-char/
OJ