WindowsMediaPlaye C++ WInform reference file error

José Carlos 886 Reputation points
2023-02-23T13:48:14.63+00:00

Friends.

I developed an application to play mp3 files in C# and it's working perfectly. I converted this application to C++ Winforms. When running, I don't have any errors, except when I click on a song name to play. I've included all WindowsMediaPlayer references. When clicking on the name of the song to play, it gives the following error:

System.IO.FileNotFoundException: Could not load file or assembly 'Interop.WMPLib.1.0, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the specified file.

File name: 'Interop.WMPLib.1.0, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

The file mentioned above is found in the solution explorer list.

Does anyone have any idea what it could be?

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
{count} votes

Answer accepted by question author
  1. Castorix31 91,501 Reputation points
    2023-02-25T23:17:14.1033333+00:00

    It works for me if I copy

    AxInterop.WMPLib.1.0.dll

    Interop.WMPLib.1.0.dll

    into the .exe folder

    Then I can create the WMP control by code :

    			AxWMPLib::AxWindowsMediaPlayer^ musica = gcnew AxWMPLib::AxWindowsMediaPlayer();
    			musica->Size = System::Drawing::Size(400, 400);
    			musica->Location = System::Drawing::Point(300, 10);			
    			this->Controls->Add(musica);
    			musica->URL = "E:\\01. IMANY - Don't Be so Shy (Filatov & Karas Remix).mp3";
    			musica->Ctlcontrols->play();
    
    

    User's image

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. YujianYao-MSFT 4,296 Reputation points Microsoft External Staff
    2023-02-24T03:05:13.7533333+00:00

    Hi José Carlos Souza,

    The problem should be in the file path, I suggest you add AxInterop.WMPLib.dll and Interop.WMPLib.dll to your project folder.

    Also, this document is worth your reference.

    Best regards,

    Elya


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. José Carlos 886 Reputation points
    2023-02-24T12:09:10.16+00:00

    Hi Yujian,

    Did not work. The program itself created a folder called Interop with the files you mentioned and others. These files are also in the Windows\System32 folder. But still having problems. Even including the WindowsMediaPlayer control doesn't work. It gives the same error. Interesting that in C# everything works.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.