在dll'之间传递本机类型

时间:2018-03-22 15:34:02

标签: c# c++ c++-cli

我有2个dll用c ++ cli编写(让他们把它们命名为dll A和dll B)。

在dll A中我有一个定义为的函数:

void func(System::String^ str1, std::string& str2);

在dll B中,我尝试将所述函数称为:

 System::String^ str1 = gcnew System::String("whatever");
    std::string str2;
    func(str1, str2);

这会生成一个编译错误,指出"无法从std :: string转换为std :: basic_string,allocator> *" 但是我注意到这不仅仅适用于std :: string,而是适用于任何本机类型(原语除外)(例如,无法从类转换为类*)。如果我在同一个dll中执行该功能,那么一切都很好。有谁知道为什么会这样?

注意:在dll B中我有#using <A.dll> as_friend 注2:两个dll都是使用相同的编译器选项编译的。

0 个答案:

没有答案