MikeNovy
June 7th, 2004, 06:48 AM
Hi,
iI just want to define a structure with an array insdie, which has an fixed size of 10 elements of byte.
But unfortunatelly C# doesn't allow to initialize my array by declaration time, but only in struct contructors.
And this is my problem:
I have to call a function (from a C++ DLL) which needs a paramater, a reference to a struct.
Generally all works fine, if the array is not included in my c# struct (and in the c++ source of the dll).
The protoyp afeter DLLimport looks in C# like this:
unsafe public static extern void miniDLL_ComplexReferenceDouble(ref sStruct structure);
THIS ONE NEEDS A STRUCT TYPE.
The struct in C#:
public struct sStruct
{
public byte number;
public byte figure;
//public byte[] byteArray = new byte[10];
}
How can I solve the problem? How can I call the function using an intialized struct, not only a definition of a struct.
I tryed the same thing with creating a class instead of a struct in C#, but since the C++ needs a Struct-Reference I have to marshal it... this doesn't work, too... since i use the Compact Framework and keywords like "MarshAls" are not recognized :-((
How can I create a struct and a ferenec to it, using it in the function call
miniDLL_ComplexReferenceDouble(...)?
iI just want to define a structure with an array insdie, which has an fixed size of 10 elements of byte.
But unfortunatelly C# doesn't allow to initialize my array by declaration time, but only in struct contructors.
And this is my problem:
I have to call a function (from a C++ DLL) which needs a paramater, a reference to a struct.
Generally all works fine, if the array is not included in my c# struct (and in the c++ source of the dll).
The protoyp afeter DLLimport looks in C# like this:
unsafe public static extern void miniDLL_ComplexReferenceDouble(ref sStruct structure);
THIS ONE NEEDS A STRUCT TYPE.
The struct in C#:
public struct sStruct
{
public byte number;
public byte figure;
//public byte[] byteArray = new byte[10];
}
How can I solve the problem? How can I call the function using an intialized struct, not only a definition of a struct.
I tryed the same thing with creating a class instead of a struct in C#, but since the C++ needs a Struct-Reference I have to marshal it... this doesn't work, too... since i use the Compact Framework and keywords like "MarshAls" are not recognized :-((
How can I create a struct and a ferenec to it, using it in the function call
miniDLL_ComplexReferenceDouble(...)?