Click here to Skip to main content
15,902,299 members
Home / Discussions / C#
   

C#

 
GeneralIf-structure Pin
bertcox18-Apr-04 22:18
bertcox18-Apr-04 22:18 
GeneralRe: If-structure Pin
Hesham Amin18-Apr-04 22:23
Hesham Amin18-Apr-04 22:23 
GeneralRe: If-structure Pin
bertcox18-Apr-04 22:32
bertcox18-Apr-04 22:32 
GeneralRe: If-structure Pin
Heath Stewart19-Apr-04 3:45
protectorHeath Stewart19-Apr-04 3:45 
GeneralRe: If-structure Pin
Nick Parker19-Apr-04 8:38
protectorNick Parker19-Apr-04 8:38 
GeneralKey event in VS2003 Pin
thomasa18-Apr-04 22:10
thomasa18-Apr-04 22:10 
GeneralRe: Key event in VS2003 Pin
Heath Stewart19-Apr-04 3:49
protectorHeath Stewart19-Apr-04 3:49 
GeneralMarshaling the structure array member of Structure in C# Pin
Vini Deep18-Apr-04 19:27
Vini Deep18-Apr-04 19:27 
Hi,

I have a structure defined in a dll which has another structure array as a member. I need to call this Dll from C#. How do I do it?

This is the structure I have in the DLL.

typedef struct FIRST_STRUCT
{
double XSpeed;
int DRate;
unsigned int RotCtrl
} FIRST_STRUCT;

typedef struct SEC_STRUCT
{
char Model[20];
unsigned int SuptTxt;
FIRST_STRUCT CurSpd;
FIRST_STRUCT MaxRdSpd;
unsigned int cNumSpd;
FIRST_STRUCT CrwWrd[40];
FIRST_STRUCT DWrd[20];
} SEC_STRUCT;

__declspec (dllexport) unsigned int CALLBACK MyFunc(SEC_STRUCT * Info);
_________________________________________________________________________

How do I call this from my C# client? I have changed the structure as

[StructLayoutAttribute(LayoutKind.Sequential)]
public struct First_struct
{
public System.Double XSpeed;
public System.Int32 DRate;
public System.UInt32 RotCtrl;
}

How do I marshal the SEC_STRUCT in C#. I tired using the MarshalAs(), but it gave me a run time error 'System.TypeLoadException'

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
public First_struct[] CrwWrd;

Kindly Help.

Thanks



Vini
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Heath Stewart19-Apr-04 4:44
protectorHeath Stewart19-Apr-04 4:44 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Vini Deep19-Apr-04 18:03
Vini Deep19-Apr-04 18:03 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Heath Stewart20-Apr-04 3:13
protectorHeath Stewart20-Apr-04 3:13 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Vini Deep20-Apr-04 19:53
Vini Deep20-Apr-04 19:53 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Heath Stewart21-Apr-04 3:07
protectorHeath Stewart21-Apr-04 3:07 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Vini Deep22-Apr-04 2:25
Vini Deep22-Apr-04 2:25 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Heath Stewart22-Apr-04 2:43
protectorHeath Stewart22-Apr-04 2:43 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Vini Deep22-Apr-04 20:36
Vini Deep22-Apr-04 20:36 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Heath Stewart23-Apr-04 2:05
protectorHeath Stewart23-Apr-04 2:05 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Vini Deep25-Apr-04 22:30
Vini Deep25-Apr-04 22:30 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Heath Stewart26-Apr-04 2:56
protectorHeath Stewart26-Apr-04 2:56 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
Vini Deep26-Apr-04 19:42
Vini Deep26-Apr-04 19:42 
GeneralRe: Marshaling the structure array member of Structure in C# Pin
poda21-Sep-10 0:16
poda21-Sep-10 0:16 
QuestionWhy didn't my raw socket work properly? Pin
pdsinfo18-Apr-04 18:29
pdsinfo18-Apr-04 18:29 
Generalwrapping .TLB to .DLL for .NET Pin
normanordas18-Apr-04 18:14
normanordas18-Apr-04 18:14 
GeneralRe: wrapping .TLB to .DLL for .NET Pin
Heath Stewart19-Apr-04 4:47
protectorHeath Stewart19-Apr-04 4:47 
GeneralRe: wrapping .TLB to .DLL for .NET Pin
normanordas22-Apr-04 16:04
normanordas22-Apr-04 16:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.