© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
1 reply
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;
});
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
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
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
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ C# native aot reflections
C#CC# / help
3y ago
Native AOT is not supported
C#CC# / help
2mo ago
❔ yaml parser with native aot
C#CC# / help
4y ago
ActivatorUtilities.CreateInstance replacment for native AOT
C#CC# / help
3y ago