callback fucntions in unmanaged code

Sep 29 2003 6:29 AM
Here is the syntax of an Unmanaged function : int PBORCA_LibraryDirectory ( int hORCASession, LPSTR lpszLibName, LPSTR lpszLibComments, int iCmntsBuffSize, PBORCA_LISTPROC pListProc, LPVOID pUserData ); pListProc- pointer to a callback function. pUserData- pointer to a structre. Ive used the following prototype in managed fucntion: public class UserData { [ MarshalAs( UnmanagedType.ByValTStr, SizeConst=20000 )] public string buffer; public ulong callcount; public ulong size; public ulong buffoffset; } [DllImport("pborc80.dll",CharSet=CharSet.Ansi,EntryPoint="PBORCA_LibraryDirectory")]//...Ansi)] public static extern int LibraryEntry(int hnd,[MarshalAs(UnmanagedType.LPStr)] string s,[Out] char[] buf,int size,callback c,[In,Out] UserData us1 ); I've also included callback fucntion through the delegates. but it's giving me the error "Object reference not set to an instance of an object" what is the apt managed prototype for this fucntion in C#?