using System; using System.Runtime.InteropServices; namespace testch { class Class1 { [ StructLayout( LayoutKind.Sequential )] public struct delegate_wrapper { public int type; public delegate void CTest(); [MarshalAs(UnmanagedType.FunctionPtr)] public CTest Test; static void WTest() { Console.WriteLine("test"); } //here may be other functions with params... internal delegate_wrapper(int _type) { type=_type; Test=new CTest(WTest); } } [DllImport("testdll.dll")] public static extern void test(int a,int i,delegate_wrapper c); [DllImport("testdll.dll",EntryPoint="test")] public static extern void test2(int a,int i,int type,delegate_wrapper.CTest c); static void Main(string[] args) { delegate_wrapper t=new delegate_wrapper(10); test(10,5,t); //correct way but not work Under MONO and Portable.NET //test2(10,5,t.type,t.Test); //Incorrect way but work anywhere } } }