Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaInfo library was not loaded! #14

Closed
lynn-orrell opened this issue Jan 6, 2020 · 14 comments
Closed

MediaInfo library was not loaded! #14

lynn-orrell opened this issue Jan 6, 2020 · 14 comments

Comments

@lynn-orrell
Copy link

I get this error message on some machines but not others. Is there any way to understand why MediaInfo.dll failed to load?

@yartat
Copy link
Owner

yartat commented Jan 6, 2020

Please, describe more information what is OS was used, version MediaInfo.Wrapper. Did you use .NET Core version or full .NET?

@lynn-orrell
Copy link
Author

Edition: Windows 10 Pro
Version: 1909
OS build: 18363.535

MediaInfo.Wrapper: 19.4.1.0

.NET Framework 4.8

@yartat
Copy link
Owner

yartat commented Jan 7, 2020

Fixed in 84003fc

@yartat yartat closed this as completed Jan 7, 2020
@ransagy
Copy link

ransagy commented Jan 8, 2020

This still seems to happen, But i'm not sure if its the exact same issue; It works when building for x64, but AnyCPU doesn't copy any of the runtime dlls, including libmediainfo etc and the other dependencies.

All machines showing this are on Windows 10. I have a netstandard2.0 library that references the .NET Core version of the wrapper (19.09) and there are two consoles that are targetting NET Framework 4.7.2 referencing this library.

@yartat
Copy link
Owner

yartat commented Jan 11, 2020

I created 2 packages: .NET full and .NET standard. .NET standard should use in .NET Core services and applications only. If you run application on .NET Framework 4.8 you should use .NET full package

@ransagy
Copy link

ransagy commented Jan 13, 2020

Not sure i follow. The project that uses this library is a netstandard2.0 one, even if the root that loads it is a .NET Framework based one.

It does work well in runtime, but only if i build for x86/x64 explicitly; it just doesn't copy any of the artifacts when building to AnyCPU. Is that just not supported in general?

I'm not sure why that would be related to which runtime executes the code.

@yartat
Copy link
Owner

yartat commented Jan 13, 2020

MediaInfo.Native package contains MediaInfo.Native.targets (you can find it in %USERPROFILE%.nuget\packages\mediainfo.native\19.9.0) file with instructions how to build in 3 cases:

  • When x64 will copy libcrypto-1_1-x64.dll, libcurl.dll (x64), libssl-1_1-x64.dll and MediaInfo.dll (x64) to target folder
  • When x86 will copy libcrypto-1_1.dll, libcurl.dll (x86), libssl-1_1.dll and MediaInfo.dll (x86) to target folder
  • When AnyCPU will create 2 folders x86 and x64 in target folder and will copy native libraries to them

MediaInfo.Wraper library detects what kind of process (x32 or x64) and tries find MediaInfo library in root folder or x86\x64 folder.

@yartat
Copy link
Owner

yartat commented Jan 13, 2020

MediaInfo.Core.Native package contains runtimes with structure of folder and libraries well known only for .NET Core runtime

@ransagy
Copy link

ransagy commented Jan 13, 2020

Then it seems unrelated to this issue, I just don't get the x86 and x64 folders in the output.
If it was a Core vs Framework issue, id expect not to get anything even when building for a specific arch.
Should i open a new issue here or on the Native package in your opinion?

@yartat
Copy link
Owner

yartat commented Jan 13, 2020

Could you create a simple project with mediainfo.wrapper package only and try build it? If you have same result as in your project can you share it with me?

@ransagy
Copy link

ransagy commented Feb 3, 2020

@yartat sorry for the delay - here is the repro: https://github.com/ransagy/mpMediaInfoBitnessRepro

Run the console project on either Any CPU or x64 and see the difference in outputs.

@yartat
Copy link
Owner

yartat commented Feb 23, 2020

@LeaFrock
Copy link

Now Microsoft recommends NFX projects using PackageReference instead of packages.config. But the MediaInfo.Native.targets reads,

 <ItemGroup Condition=" (Exists('packages.config') Or Exists('packages.$(MSBuildProjectName).config')) And '$(Platform)' == 'x86'">
    <None Include="$(MSBuildThisFileDirectory)native\x86\*">
      <Link>%(Filename)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>False</Visible>
    </None>
  </ItemGroup>

The Condition prevents CopyToOutputDirectory so I have to copy the .dlls (in native/x86) manually and it works well. And I believe I'm not alone so it's worth leaving a comment here.

The following is a very small console sample:

    internal class Program
    {
        private static void Main(string[] args)
        {
            string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test2.mp3");
            var media = new MediaInfoWrapper(filePath, NullLogger.Instance);
            if (media.Success)
            {
                Console.WriteLine(media.Duration.ToString());
            }
            Console.ReadKey();
        }
    }

    internal sealed class NullLogger : MediaInfo.ILogger
    {
        public static readonly NullLogger Instance = new NullLogger();

        public void Log(LogLevel loglevel, string message, params object[] parameters)
        {
            try
            {
                if (parameters?.Length > 0)
                {
                    Console.WriteLine(string.Format(message, parameters));
                }
                else
                {
                    Console.WriteLine(message);
                }
            }
            catch(Exception)
            {
                ;
            }
        }
    }

1668670146168

@w7rus
Copy link

w7rus commented Dec 24, 2022

Using mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim or mcr.microsoft.com/dotnet/aspnet:7.0 had same MediaInfo library was not loaded! error.
MediaInfo.Core.Native & MediaInfo.Wrapper.Core are installed for project.

As a temporary solution: manually installing required libraries fixes the problem

RUN apt update &&\
    apt-get install -y libmediainfo0v5 libzen0v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants