A
Alain Dekker
Hi,
I've got a structure in a C# DLL defined as follows:
// DLL struct
public struct DataLinkDiag
{
public int data1; // Count of data1 calls
public int data2; // Count of data2 calls
}
And I've defined a function in the DLL to return the structure
// DLL code continued
public static DataLinkDiag diag;
// ... maybe set some members of the structure like diag.data1++; and so on
public static DataLinkDiag GetDatalinkDiag()
{
return diag;
}
Now in the C# application I have defined the same structure (exactly as
above) and then I try and populate a local variable from the DLL:
// C# application code
CCommonDefinitions.DataLinkDiag datalinkDiag = new
CCommonDefinitions.DataLinkDiag();
// ...
datalinkDiag =MyDll.GetDatalinkDiag();
The DLL compiles fine. But when I compile the C# application, it fails with
this compiler message:
Cannot implicitly convert type MyDll.DataLinkDiag' to
'CCommonDefinitions.DataLinkDiag'
What am I doing wrong? This was easy to do in C++ if I remember correctly.
Thanks,
Alain
I've got a structure in a C# DLL defined as follows:
// DLL struct
public struct DataLinkDiag
{
public int data1; // Count of data1 calls
public int data2; // Count of data2 calls
}
And I've defined a function in the DLL to return the structure
// DLL code continued
public static DataLinkDiag diag;
// ... maybe set some members of the structure like diag.data1++; and so on
public static DataLinkDiag GetDatalinkDiag()
{
return diag;
}
Now in the C# application I have defined the same structure (exactly as
above) and then I try and populate a local variable from the DLL:
// C# application code
CCommonDefinitions.DataLinkDiag datalinkDiag = new
CCommonDefinitions.DataLinkDiag();
// ...
datalinkDiag =MyDll.GetDatalinkDiag();
The DLL compiles fine. But when I compile the C# application, it fails with
this compiler message:
Cannot implicitly convert type MyDll.DataLinkDiag' to
'CCommonDefinitions.DataLinkDiag'
What am I doing wrong? This was easy to do in C++ if I remember correctly.
Thanks,
Alain