When I used zstdnet in web applications, it throwed System.DllNotFoundException: libzstd. I review ed the loading native DLL's source code(ExternMethods class) , found a bug that set directory dll error in SetWinDllDirectory method,as follows:
var location = Assembly.GetExecutingAssembly().Location;
In web application, it will get temporary asp.net files directory, not the native dll directory.
I suggest the code modify following:
using System.Web;
var isWebApplication = false;
if(HttpContext.Current!=null){
isWebApplication = true;
}
var location = string.empty;
if(isWebApplication){
//get web application bin direcotry
location = $"{System.AppDomain.CurrentDomain.BaseDirectory}bin/";
}else{
location = Assembly.GetExecutingAssembly().Location;
}
When I used zstdnet in web applications, it throwed System.DllNotFoundException: libzstd. I review ed the loading native DLL's source code(ExternMethods class) , found a bug that set directory dll error in SetWinDllDirectory method,as follows:
var location = Assembly.GetExecutingAssembly().Location;
In web application, it will get temporary asp.net files directory, not the native dll directory.
I suggest the code modify following:
using System.Web;
var isWebApplication = false;
if(HttpContext.Current!=null){
isWebApplication = true;
}
var location = string.empty;
if(isWebApplication){
//get web application bin direcotry
location = $"{System.AppDomain.CurrentDomain.BaseDirectory}bin/";
}else{
location = Assembly.GetExecutingAssembly().Location;
}