How to fix an exception: Could not load file or assembly 'Microsoft.DirectX.AudioVideoPlayback, Version =1.0.2902.0....'

Zhe-Yu Lee 0 Reputation points
2024-07-17T02:53:02.9166667+00:00

I was writing a C# WinForm which can play videos. I'd add the reference, 'Microsoft.DirectX.AudioVideoPlayback.dll' and compile was ok, but it failed when running with the mentioned exception. I'd searched the question through internet and I found that 'Microsoft.DirectX.dll' was also required. But I still failed after 'Microsoft.DirectX.dll' was added.

The version of 'Microsoft.DirectX.AudioVideoPlayback.dll' is 5.4.0.2904 and the one of 'Microsoft.DirectX.dll' is 9.15.779.0. Does they have to meet each others' version? Is that the problem? I thought they were downward compatible. I couldn't find other versions for 'Microsoft.DirectX.AudioVideoPlayback.dll' while I did find another one for 'Microsoft.DirectX.dll', which was exactly 5.4.0.2904. I chose 9.15.779.0 because someone said the version of DirectX must remain the latest or else you'll meet another exception: Could not load ... 'Microsoft.DirectX, Version....'. I also noticed that the exception I encountered requires version =1.0.2902.0. I am not familiar to if the version is available or not and I'll be glad if someone can explain. My version of .NET is .NET 8.0. and Visual Studio is 2022.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,609 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,615 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiale Xue - MSFT 42,411 Reputation points Microsoft Vendor
    2024-07-17T07:08:59.8633333+00:00

    Hi @Zhe-Yu Lee , Welcome to Microsoft Q&A,

    You can use the Windows Media Player controls instead to achieve what you need.

    1. Open Visual Studio and load your WinForm project.
    2. Open the Toolbox, right-click anywhere in the Toolbox, and select "Choose Items... )。
    3. In the dialog box that pops up, switch to the "COM Components" tab.
    4. Find and tick "Windows Media Player" and click "OK"
    using System;
    using System.Windows.Forms;
    
    namespace VideoPlayer
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                // Set the path of the video file
                axWindowsMediaPlayer1.URL = @"C:\path\to\your\video.mp4";
                // Start playing the video
                axWindowsMediaPlayer1.Ctlcontrols.play();
            }
        }
    }
    

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly 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.

    0 comments No comments