I try to load the custom library in my app, and I get a Bad IL Format error. Here is my code:
var architectureFolder = (IntPtr.Size == 8) ? "64 bit" : "32 bit";
var wkHtmlToPdfPath = Path.Combine(_hostingEnvironment.ContentRootPath, $"wkhtmltox\\v0.12.4\\{architectureFolder}\\libwkhtmltox.dll");
AssemblyLoadContext context = new AssemblyLoadContext(GetType().Assembly.GetName().Name);
context.LoadFromAssemblyPath(wkHtmlToPdfPath);
Error details:
System.BadImageFormatException HResult=0x8007000B Message=Bad IL format. Source= StackTrace:
The library I try to load is libwkhtmltox. I am using this in my ASP.net zero boilerplate app, and in my Host project i can load the same asembly with:
var architectureFolder = (IntPtr.Size == 8) ? "64 bit" : "32 bit";
var wkHtmlToPdfPath = Path.Combine(_hostingEnvironment.ContentRootPath, $"wkhtmltox\\v0.12.4\\{architectureFolder}\\libwkhtmltox");
CustomAssemblyLoadContext context = new CustomAssemblyLoadContext();
context.LoadUnmanagedLibrary(wkHtmlToPdfPath);
How can I load the assembly in my public project?
User contributions licensed under CC BY-SA 3.0