Hi,
I have the following structures in a C dll,
Code:
In C: 

typedef struct Structure1
{
	SomeStruct list1;// Somestruct is a structure
	SomeStruct List2;
	SomeEnum state; // SomeEnum is a Enum
	unsigned char *pcurrent;
	unsigned short Length;
	SomeStruct addr;
	SomeStruct timer;
	unsigned short retries;
	unsigned char flag;
	unsigned short seq;
	someEnum2 Mtype;
	unsigned char action;
	unsigned int size;
	unsigned char *ptr; //data segment
}struct1;

typedef struct Structure2
{
	struct1 Msg;	
}struct2;

for the above structures, i have written the following structures in C#,

Code:
In C#:

        [StructLayout(LayoutKind.Sequential)]
        public struct struct1
        {
            public int List1;
            public int List2;
            public someenum State;
            public int pCurrent;
            public short Len;
            public int Addr;
            public int Timer;
            public ushort Retries;
            public char Flags;
            public ushort SeqNum;
            public ushort InvokeId;
            public someenum MType;
            public char Action;
            public int DataBuffSize;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10000)]
            public byte[] ptr;
        }

[StructLayout(LayoutKind.Sequential)]
        public struct struct2
        {
            public struct1 Msg;
        }
and i have the following callback function in the managedcode.

Code:
In C#:

public void CallBack(long hDev, ref struct2 pData);
This callback function is invoked by a function in unmanaged code.
I have written the following delegate for the callback function,

Code:
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CallBack_delegate(long hDev, ref struct2 pData);

public static CallBack_delegate call_del = CallBack;
I am getting Access violation exception when the call back funciton is executed.

pls help.