U
Urs Wigger
In a C++ project, I have the following struct definition:
struct GridModeDataT
{
double dVal1;
double dVal2;
double dVal3;
long lNumberOfPoints;
int bUseRegion;
enum ES_RegionType regionType;
};
I did a Managed C++ wrapper class around my C++ project. This MC++
wrapper defines a virtual function 'OnGetGridModeParamsAnswer()', which
uses a parameter of the above struct type.
Finally, in a C# project, I inherit from the class in the MC++ project
and override the virtual function, as shown here:
public override void OnGetGridModeParamsAnswer(GridModeDataT gridModeData)
{
Console.WriteLine("Derived OnGetGridModeParamsAnswer() was called");
}
Everything compiles and runs correctly. If I look to 'gridModeData'
within the debuggers 'Watch' window, the struct members are correctly
resolved and assigned. For example it looks as follows in the watch window:
gridModeData {GridModeDataT} GridModeDataT
bUseRegion 0 int
dVal1 1.0 double
dVal2 2.0 double
dVal3 3.0 double
lNumberOfPoints 4 int
regionType 1 ES_RegionType
Now the problem: If I try to reference the struct members in C# code,
the compiler says there are no such members:
public override void OnGetGridModeParamsAnswer(GridModeDataT
gridModeData)
{
double dVal1 = gridModeData.dVal1; // compiler says:
'GridModeDataT' does not contain a definition for 'dVal1'
Console.WriteLine("Derived OnGetGridModeParamsAnswer() was called");
}
The 'intellisense' only offers the the following methods on
gridModeData: 'Equals', 'GetHashCode', 'GetType', 'ToString'.
I don't understand why I can't access the 'original' struct members,
although the debugger can 'see' them.
How do I have to work around this problem?
Any help is appreciated.
Regards Urs
struct GridModeDataT
{
double dVal1;
double dVal2;
double dVal3;
long lNumberOfPoints;
int bUseRegion;
enum ES_RegionType regionType;
};
I did a Managed C++ wrapper class around my C++ project. This MC++
wrapper defines a virtual function 'OnGetGridModeParamsAnswer()', which
uses a parameter of the above struct type.
Finally, in a C# project, I inherit from the class in the MC++ project
and override the virtual function, as shown here:
public override void OnGetGridModeParamsAnswer(GridModeDataT gridModeData)
{
Console.WriteLine("Derived OnGetGridModeParamsAnswer() was called");
}
Everything compiles and runs correctly. If I look to 'gridModeData'
within the debuggers 'Watch' window, the struct members are correctly
resolved and assigned. For example it looks as follows in the watch window:
gridModeData {GridModeDataT} GridModeDataT
bUseRegion 0 int
dVal1 1.0 double
dVal2 2.0 double
dVal3 3.0 double
lNumberOfPoints 4 int
regionType 1 ES_RegionType
Now the problem: If I try to reference the struct members in C# code,
the compiler says there are no such members:
public override void OnGetGridModeParamsAnswer(GridModeDataT
gridModeData)
{
double dVal1 = gridModeData.dVal1; // compiler says:
'GridModeDataT' does not contain a definition for 'dVal1'
Console.WriteLine("Derived OnGetGridModeParamsAnswer() was called");
}
The 'intellisense' only offers the the following methods on
gridModeData: 'Equals', 'GetHashCode', 'GetType', 'ToString'.
I don't understand why I can't access the 'original' struct members,
although the debugger can 'see' them.
How do I have to work around this problem?
Any help is appreciated.
Regards Urs