/// <summary> /// Get the path to the right file /// </summary> /// <param name="wkhtmltoxData"></param> /// <returns>string path</returns> private static string PathToLib(WkhtmltoxData wkhtmltoxData) { // Get the Folder's name var foldersName = GetArchitectureNameFolder(); // Create the project path var projectPath = string.Format("{1}{0}{2}{0}libwkhtmltox", Path.DirectorySeparatorChar, baseFolderPath, foldersName); // Get the path string path = Path.Combine(wkhtmltoxData.HostingEnvironment.ContentRootPath, projectPath); // Return the path return(path); }
/// <summary> /// This method load the Wkhtmltox Library /// </summary> /// <param name="wkhtmltoxData"></param> /// <returns>IntPtr intPtr</returns> public static IntPtr LoadLibrary(WkhtmltoxData wkhtmltoxData) { //New instance of AssemblyLoad WkhtmltoxLibsAssemblyLoadContext wkhtmltoxLibsAssemblyLoadContext = new WkhtmltoxLibsAssemblyLoadContext(); //Get the pathe to library string pathToTheLibrary = PathToLib(wkhtmltoxData); //Load the Library IntPtr intPtr = wkhtmltoxLibsAssemblyLoadContext.LoadUnmanagedLibraryByAbsolutePath(pathToTheLibrary); //Return the intPtr return(intPtr); }