[英]c++ call a c# DLL with Hashtable parameter
I'm trying to call a C# DLL from C++ using CLI as this link: http://tom-shelton.net/index.php/2008/11/01/calling-managed-code-from-a-dll-created-in-visual-c-2008/ 我正在尝试使用CLI作为此链接从C ++调用C#DLL: http : //tom-shelton.net/index.php/2008/11/01/calling-managed-code-from-a-dll-created -in-visual-c-2008 /
Everything seem be fine. 一切似乎都很好。
But if the C# function has got a Hashtable parameter, I don't know how to call it. 但是,如果C#函数具有Hashtable参数,则我不知道如何调用它。 C# function like this:
C#函数如下所示:
public void DoSomething(Hashtable htb,int,string etc)
Please help me to how to use this kind of C# function in C++. 请帮助我如何在C ++中使用这种C#函数。
Best regards 最好的祝福
John 约翰
After try some failed times, I decided to solve like this I declare a class 经过一些失败的尝试后,我决定像这样解决我声明一个类
Class WrappedWhateverClass
{
private:
gcroot <CSharpClass ^> _caller;
public:
gcroot <Hashtable^> htb;
void WrappedWhateverClass()
int DoSomethinginC( int , string, etc);
}
In code, I call the C# DoSomething function: 在代码中,我调用C#DoSomething函数:
void WrappedWhateverClass::WrappedWhateverClass()
{
htb = gcnew Hashtable();
}
int WrappedWhateverClass::DoSomethinginC( int i, string str, etc)
{
_caller->DoSomething(htb,i,str, etc);
}
If you use CLR option then your c++ code becomes managed code. 如果使用CLR选项,则您的c ++代码将成为托管代码。 so you can use
所以你可以使用
System::Collections::Hashtable
in your c++ code to use Hashtable 在您的C ++代码中使用Hashtable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.