Passing structure form VC++ to C# Dll
-
Hi, im using C# dll in VC++ application.I have somedetails in VC++ like PageNumer pageTitle PageDesc BoxDetail . I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help me. VC++ Function:
struct SCS3OverVwPg
{
__int32 iOvrPgNo;
char sOvrPgTitle[30]; //OverView Page Title
};void CToolTab::SendOverview()
{
SCS3OverVwPg *pOverVw = 0;
pOverVw = new SCS3OverVwPg;
Globals1::gwtoolbar->SetTree(pOverVw);
}C# function:
public struct SCS3Over
{
Int32 iOvrPgNo;
char[] sOvrPgTitle;
}public void SetTree(SCS3Over x)
{
MessageBox.Show("Data received");
}If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over' If i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.
Anu
-
Hi, im using C# dll in VC++ application.I have somedetails in VC++ like PageNumer pageTitle PageDesc BoxDetail . I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help me. VC++ Function:
struct SCS3OverVwPg
{
__int32 iOvrPgNo;
char sOvrPgTitle[30]; //OverView Page Title
};void CToolTab::SendOverview()
{
SCS3OverVwPg *pOverVw = 0;
pOverVw = new SCS3OverVwPg;
Globals1::gwtoolbar->SetTree(pOverVw);
}C# function:
public struct SCS3Over
{
Int32 iOvrPgNo;
char[] sOvrPgTitle;
}public void SetTree(SCS3Over x)
{
MessageBox.Show("Data received");
}If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over' If i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.
Anu
the structure (SCS3Over ) in c# dll is public? if it's public you can directly use it in visual c++ without having to redeclare it...so your visual c code:
//struct SCS3OverVwPg //{ // __int32 iOvrPgNo; // char sOvrPgTitle[30]; //OverView Page Title //}; void CToolTab::SendOverview() { //SCS3OverVwPg *pOverVw = 0; //pOverVw = new SCS3OverVwPg; Globals1::SCS3Over tmp; //use the correct namespace to go to SCS3Over tmp.iOvrPgNo=1; tmp.sOvrPgTitle="ciao"; Globals1::gwtoolbar->SetTree(tmp); }