Skip to content

System.DllNotFoundException: libzstd #15

@owenStarry

Description

@owenStarry

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions