【问题标题】:How to receive strings from C# in Visual-C++ based .net DLL?如何在基于 Visual-C++ 的 .net DLL 中从 C# 接收字符串?
【发布时间】:2010-08-21 22:15:33
【问题描述】:

如何在基于 Visual-C++ 的 .net DLL 中接收来自 C# 的字符串?

在 C++ 中(使用 clr)我有这个代码:

#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(){}
  };
};

但在 .net C# 中,我只看到一个函数 init_2。如何使init_1 在.net 中可见?

【问题讨论】:

    标签: c# .net c++ visual-c++ dll


    【解决方案1】:

    你不能使用std::string,你应该使用System::String^:

    static void init_1(System::String^ a, System::String^ b);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 2019-03-17
    • 2013-07-28
    • 2017-10-20
    • 2020-05-08
    • 2013-10-06
    • 1970-01-01
    相关资源
    最近更新 更多