【发布时间】:2011-12-29 05:50:26
【问题描述】:
我一直在尝试开发用于 C# 的 C++/CLI 库,但遇到以下问题。如果我们将我的托管引用类如下:
namespace Library
{
using namespace System;
public ref class Test
{
internal:
String^ internalString;
public:
Test()
{
internalString = gcnew String("Hey There");
}
~Test()
{
}
};
public ref class TestImplement
{
public:
static String^ TestMessage(Test test)
{
return test.internalString;
}
};
}
而我的C#实现如下:
使用系统;
namespace AddProgram
{
class Program
{
static void Main(string[] args)
{
Library.Test test = new Library.Test();
Console.WriteLine(Library.TestImplement.TestMessage(test));
Console.Read();
}
}
}
我收到以下错误:
错误 CS0570:该语言不支持“TestMessage”
据我所知,这是由于将类型 Library.Test 作为参数传递。我不明白为什么会收到此消息,我希望可以从我的参考库中传递类型。
任何帮助将不胜感激
【问题讨论】:
-
在 C++/CLI 中注意你的帽子和析构函数。
标签: .net c#-4.0 interop c++-cli