// public delegate RETURN_TYPE DllFunctionDelegate(int a, string b); public static int FunctionName(int a, string b) //public static RETURN_TYPE functionName(int a, string b) { if (_myDll == IntPtr.Zero) { InitializeMyDll(); } var pProc = Dll.GetProcAddress(_myDll, "CallingFunctionNameFromCallingDllFile"); var cpv = (DllFunctionDelegate)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DllFunctionDelegate)); // Now i'm calling delegate, with is calling function from dll file return(cpv(1, "Test")); }
public static void InitializeMyDll() { try { _myDll = Dll.LoadWin32Library("path to my dll with file path name"); // here you can add, dl version check } catch (ApplicationException exc) { Debug.WriteLine(exc.Message, "There was an error during dll loading"); throw; } }