C#C
C#10mo ago
Nebula

Native AoT dependency issues

I'm not familiar with how any of these concepts work - I just found a library called NPlug (for developing VSTs using C#), and it uses PublishAot to compile.

When I try to add any dependencies, like SkiaSharp or OpenTK, the vst can't find the dlls. I managed to brute force it for SkiaSharp like this:
NativeLibrary.SetDllImportResolver(typeof(SkiaSharp.SKImage).Assembly, (libraryName, assembly, searchPath) =>
{
    if (libraryName == "libSkiaSharp")
    {
        return NativeLibrary.Load(skiaSharpLocation);
    }
    return IntPtr.Zero;
});


But openTK prints (when making a gamewindow):
Error: System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at OpenTK.Windowing.Desktop.GLFWProvider.EnsureInitialized() + 0xbe
   ...4


I tried setting the dll resolver for GLFWProvider to point to glfw3.dll , but that didn't work.

I have selfcontained enabled, and I'm publishing via:
dotnet publish -c Release -r win-x64 -p:PublishAot=true

This produces the binaries for SkiaSharp, glfw, and ManagedBass. The vst3 can't see these dlls, and I'm wondering if there's a way to package the binaries together.

Sorry if this is missing anything, I'm not really sure on how this all works.
Was this page helpful?