Skip to content

Can't load DlibDotNetNativeDnn in Blazor WebAssembly project #303

@alexsosa2000

Description

@alexsosa2000

Summary of your issue

I'm trying to use DlibDotNet in a Blazor WebAssembly project and I'm getting DllNotFoundException: DlibDotNetNativeDnn. I think this may be because DlibDotNet doesn't have a wasm build.

I'm basically getting an image from the user, detecting the face with Dlib, and drawing a rectangle. But when I call Dlib.GetFrontalFaceDetector(), it throws the exception.

The same code works in a console app running in the same machine.

Environment

Blazor WebAssembly (.NET)
DlibDotNet nuget package v19.21.0.20220724

Example code:

To repro:

  • Create a Blazor WebAssembly project
  • Add a package reference to DlibDotNet
  • Add the following code to a page / component:
using (var fd = Dlib.GetFrontalFaceDetector())
{
	var img = Dlib.LoadPng<RgbPixel>(imgArray);

	// find all faces in the image
	var faces = fd.Operator(img);

	return faces;
}
  • Launch in the browser so it executes this code
  • You'll see an error in the console (DevTools - F12)

Output:

Error: System.TypeInitializationException: The type initializer for 'DlibDotNet.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: DlibDotNetNativeDnn
   at DlibDotNet.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at DlibDotNet.Dlib.GetFrontalFaceDetector()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions