/// <summary> /// Initializes a new instance of the <see cref="NativeLibrary"/> class. /// </summary> /// <param name="fileName">full path name of dll to load</param> /// <exception cref="System.IO.FileNotFoundException"> /// If fileName can't be found /// </exception> /// <remarks> /// This constructor loads a DLL and makes this class responible for /// freeing it. Throws exceptions on failure. Most common failure would be /// file-not-found, or that the file is not a loadable image. /// </remarks> public NativeLibrary(string fileName) { this.libraryHandle = NativeMethods.LoadLibrary(fileName); if (this.libraryHandle.IsInvalid) { int hr = Marshal.GetHRForLastWin32Error(); Marshal.ThrowExceptionForHR(hr); } }
internal static extern IntPtr GetProcAddress(NativeLibrarySafeHandle hModule, [MarshalAs(UnmanagedType.LPStr)]string procName);
internal static extern IntPtr GetProcAddress(NativeLibrarySafeHandle hModule, [MarshalAs(UnmanagedType.LPStr)] string procName);