7 Replies - 267 Views - Last Post: 13 September 2019 - 07:23 PM Rate Topic: -----

#1 Bauhaus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 10-September 19

"Unable to load MediaInfo library"

Posted 13 September 2019 - 11:35 AM

I'm new to c# and I'm trying to write a movie database that retrieves data from IMDB. For the codecs I found MediaInfo. The included example in winforms works fine, but when I try to use the library in my console application I get the error "Unable to load MediaInfo library".
I did:

Put MediaInfo.dll in \bin\debug
Included the file MediaInfoDLL.cs in my project
In the source code added "using MediaInfoLib;"

So why do I get the error ?

Sourcecode:

class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            var mi = new MediaInfo();
            mi.Open(@"H:\\watch\\Fitzcarraldo.mkv");
            Console.WriteLine(mi.Inform());
            Console.ReadKey();
            mi.Close();
        }
    }



Is This A Good Question/Topic? 0
  • +

Replies To: "Unable to load MediaInfo library"

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15313
  • View blog
  • Posts: 61,406
  • Joined: 12-June 08

Re: "Unable to load MediaInfo library"

Posted 13 September 2019 - 11:50 AM

That chunk of code does not reflect what you say it does.

Did you add any references?

Put a try/catch around the line and get the exception message. Post that here.
Was This Post Helpful? 0
  • +
  • -

#3 Bauhaus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 10-September 19

Re: "Unable to load MediaInfo library"

Posted 13 September 2019 - 12:00 PM

No, the program doesn't crash or throws an exception. The line "Unable to load MediaInfo library" shows up in the console window.
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7100
  • View blog
  • Posts: 24,122
  • Joined: 05-May 12

Re: "Unable to load MediaInfo library"

Posted 13 September 2019 - 01:20 PM

I'm assuming that you are using this MediaInfoLib.

If so, at the top of their sample file: HowToUse_Dll.cs, it says this:
// Microsoft Visual C# example
//
// To make this example working, you must put MediaInfo.Dll and Example.ogg
// in the "./Bin/__ConfigurationName__" folder
// and add MediaInfoDll.cs to your project



Did you do those steps?

Also if you downloaded the pre-compiled binaries from their commercial site, make sure that the bitness of your compilation of C# program matches bitness of the binaries you downloaded. E.g. If you downloaded the 32-bit libraries, that you configure your C# program to build for 32-bits. If you downloaded the 64-bit libraries, you configure your C# program to build for 64-bits.

The same concerns apply if you are building the DLL from source. If you build the native code for 32-bits, then you need to build your managed C# code for 32-bits.
Was This Post Helpful? 0
  • +
  • -

#5 Bauhaus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 10-September 19

Re: "Unable to load MediaInfo library"

Posted 13 September 2019 - 03:49 PM

I got the libray here: My link
It's the last one on the page: MediaInfo_DLL_0.7.51_Windows_x64_WithoutInstaller
However I noticed there's an assembly file in the example that isn't in my app:
using System.Reflection;
using System.Runtime.CompilerServices;

//
// Les informations générales relatives à un assembly dépendent de 
// l'ensemble d'attributs suivant. Pour modifier les informations
// associées à un assembly, changez les valeurs de ces attributs.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]		

//
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
//      Version principale
//      Version secondaire 
//      Numéro de build
//      Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer des numéros de révision et de build par défaut 
// en utilisant '*', comme ci-dessous :

[assembly: AssemblyVersion("1.0.*")]

//
// Pour signer votre assembly, vous devez spécifier la clé à utiliser. Consultez 
// la documentation Microsoft .NET Framework pour plus d'informations sur la signature d'un assembly.
//
// Utilisez les attributs ci-dessous pour contrôler la clé utilisée lors de la signature. 
//
// Remarques : 
//   (*) Si aucune clé n'est spécifiée, l'assembly n'est pas signé.
//   (*) KeyName fait référence à une clé installée dans le fournisseur de
//       services cryptographiques (CSP) de votre ordinateur. KeyFile fait référence à un fichier qui contient
//       une clé.
//   (*) Si les valeurs de KeyFile et de KeyName sont spécifiées, le 
//       traitement suivant se produit :
//       (1) Si KeyName se trouve dans le CSP, la clé est utilisée.
//       (2) Si KeyName n'existe pas mais que KeyFile existe, la clé 
//           de KeyFile est installée dans le CSP et utilisée.
//   (*) Pour créer KeyFile, vous pouvez utiliser l'utilitaire sn.exe (Strong Name, Nom fort).
//        Lors de la spécification de KeyFile, son emplacement doit être
//        relatif au répertoire de sortie du projet qui est
//       %Project Directory%\obj\<configuration>. Par exemple, si votre KeyFile se trouve
//       dans le répertoire du projet, vous devez spécifier l'attribut 
//       AssemblyKeyFile sous la forme [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
//   (*) DelaySign (signature différée) est une option avancée. Pour plus d'informations, consultez la
//       documentation Microsoft .NET Framework.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]


I tried to copy this file in my project but then he says all the fields are duplicates.

This post has been edited by Skydiver: 13 September 2019 - 06:16 PM
Reason for edit:: Put code in code tags. Learn to do this yourself.

Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7100
  • View blog
  • Posts: 24,122
  • Joined: 05-May 12

Re: "Unable to load MediaInfo library"

Posted 13 September 2019 - 06:36 PM

You don't need another AssemblyInfo.cs. If you created your own C# project using Visual Studio, VS would have provided one for you already in your project's Properties folder.

Anyway, first make sure that you put the MediaInfo.DLL in the bin\Debug or bin\Release of your project as it said at the top of that file I linked to.

Next, it looks like you downloaded the 64-bit version the DLL. You have to make sure that you are building your project for 64-bits. You want to make sure that:
  • You are using a 64-bit OS.
  • You have set your project to build for 64-bit:
    Posted Image

Was This Post Helpful? 1
  • +
  • -

#7 Bauhaus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 10-September 19

Re: "Unable to load MediaInfo library"

Posted 13 September 2019 - 07:15 PM

YES ! I finally got it to work, THANK YOU !
Changing "Any cpu" to x64 did it.
(Oddly, the example file is set to "Any cpu" and that did work.... perhaps the example is for 32 bit ?)


Nope, exmaple project is for 64 bit too, just tried it.

This post has been edited by Skydiver: 13 September 2019 - 07:24 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#8 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7100
  • View blog
  • Posts: 24,122
  • Joined: 05-May 12

Re: "Unable to load MediaInfo library"

Posted 13 September 2019 - 07:23 PM

If you have "Any CPU" selected, make sure that the "Prefer 32-bit" is not checked.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1