/// <summary>
        /// Loads the libzstd.dll assembly.
        /// </summary>
        internal static void LoadLibzstdLibrary()
        {
            // If the library has already been loaded, there is no need to load it again.
            if (LibZstdLoaded != null)
            {
                return;
            }

            // Attempt to load the library from an embedded resource.
            LibZstdLoaded = UnmanagedLibraryLoader.LoadUnmanagedLibraryFromEmbeddedResources("MySql.Data", "libzstd.dll");

            // If loading from an embedded resource fails, attempt to load it from a file in the output folder.
            if (LibZstdLoaded == false)
            {
                ZstandardInterop.LoadLibzstdLibrary(string.Empty);
                try
                {
                    // Creating this temporary stream to check if the library was loaded succesfully.
                    using (var testStream = new ZstandardStream(new MemoryStream(), CompressionMode.Compress))
                    { }

                    LibZstdLoaded = true;
                }
                catch {}
            }

            // If all attempts fail, log a warning and update the client supported compression algorithms.
            if (LibZstdLoaded == false)
            {
                MySqlTrace.LogWarning(-1, ResourcesX.CompressionFailedToLoadLibzstdAssembly);
            }
        }
Esempio n. 2
0
        private void InvokeFunction(CallData callData)
        {
            CallResult callResult = UnmanagedLibraryLoader.InvokeUnmanagedFunction(callData);

            _pipeServer.SendCallResponse(callResult);
        }