DLL Name Mapping Issue With GStreamer in .NET Framework 4.6

Viewed 62

I'm attempting to incorporate GStreamer into a .NET Framework 4.6 application that I'm working on. I'm installing GStreamer following these instructions here. I'm hooking it up with the GStreamer.Sharp.Connector nuget package. The problem I'm having is that package is looking for gstreamer-1.0-0.dll but my install is creating "libgstreamer-1.0-0.dll". I think I read somewhere that the "lib" prefix has something to do with Windows 10 but I can't seem to find much info on why.

Before trying to incorporate it into my .NET Framework app, I built a quick .NET Core app and wired everything up using the gstreamer-sharp-netcore nuget package and was able to get it working no problem. After failing to get it working with .NET Framework I looked into how the core project worked and it's using the following code to work around the "lib" issue I'm having with Framework.

            if(!NativeLibrary.TryLoad(mappedName, assembly, dllImportSearchPath, out handle))
            {
                if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    if(mappedName.StartsWith("lib", true, null))
                    {
                        NativeLibrary.TryLoad(mappedName.Substring(3), assembly, dllImportSearchPath, out handle);
                    }
                    else
                    {
                        NativeLibrary.TryLoad($"lib{mappedName}", assembly, dllImportSearchPath, out handle);
                    }
                }
           }

Unfortunately, NativeLibrary doesn't exist in Framework. I did notice that .NET Framework 5.0 has a delegate you can use with similar results when doing DllImports but it's not available in 4.6 and we're unable to upgrade our framework version at this time.

My questions are:

  1. Why does my install add "lib" to the front of every DLL? It seems like by all accounts this shouldn't be happening since all of the code samples refer to the DLLs without the "lib" prefix.

  2. Outside of rewriting my own nuget package, what options do I have for getting this thing to work? It's frustrating that 3 little letters are causing me a massive amount of work when I feel like there should be a simple solution.

  3. Is there a way to hook the [DllImport] attribute in .NET 4.6 and tell it to look for the correct DLLs?

0 Answers
Related