yartat / MP-MediaInfo

Mediaportal MediaInfoLib wrapper
Other
45 stars 21 forks source link

MediaInfo.dll not found when building for x86 or for x64 #6

Closed kitgrose closed 5 years ago

kitgrose commented 5 years ago

This issue seems very similar to #2 and possibly related to #3.

When I build a new project explicitly targeting x86 or x64 directly, MediaInfo.dll and its related dependencies are all copied to the general output directory (e.g. bin\x86\Debug\MediaInfo.dll), but when I build the project with the Any CPU platform selected, MediaInfo.dll and related dependencies are copied into a subfolder for each architecture (e.g. bin\Debug\x86\MediaInfo.dll).

MediaInfo.Wrapper.dll always expects to find MediaInfo.dll in a subdirectory which causes the Any CPU version to work and the x86-specific version to fail (with MediaInfoNotloaded set to true).

We require our project to target x86 specifically for other reasons, so the only workaround I can see to address this (without forking this project) is to add a post build step to move those five MediaInfo files (libcrypto-1_1.dll, libcurl.dll, libssh2.dll, libssl-1_1.dll and MediaInfo.dll) into a new x86 subdirectory.

I've been able to reproduce this fairly trivially in a standalone project as follows:

  1. Create a new console project in Visual Studio
  2. Add MediaInfo.Wrapper as a NuGet dependency for your project
  3. Add an example video to the project (mine is named testvideo-5s.mp4) and set it to copy to the output directory
  4. In Program.cs, add the following code:

    var info = new MediaInfoWrapper("testvideo-5s.mp4");
    
    if (info.MediaInfoNotloaded)
    {
        Console.WriteLine("Failed to load");
    }
    else
    {
        Console.WriteLine("Loaded successfully");
    }
  5. Set the project's configuration to build for the x86 platform only.
  6. Build and run, and observe "Failed to load"
  7. Set the project's configuration to build for Any CPU
  8. Build and run, and observe "Loaded successfully"
yartat commented 5 years ago

Fixed in 18.12.1