Question

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/

Everything seem be fine.

But if the C# function has got a Hashtable parameter, I don't know how to call it. C# function like this:

public void DoSomething(Hashtable htb,int,string etc)

Please help me to how to use this kind of C# function in C++.

Best regards

John

Était-ce utile?

La solution 2

If you use CLR option then your c++ code becomes managed code. so you can use

System::Collections::Hashtable

in your c++ code to use Hashtable

Autres conseils

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:

void WrappedWhateverClass::WrappedWhateverClass()
{
htb = gcnew Hashtable();
}
int WrappedWhateverClass::DoSomethinginC( int i, string str, etc)
{
_caller->DoSomething(htb,i,str, etc);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top