0

I have a menustrip in my form1 designer. In top of form1:

The Video is Microsoft.Directx.AudioVideoPlayBack.Video

Video vdo;

Then in the menustrip open menu click event:

private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (vdo != null)
            {
                vdo.Stop();
                timer1.Stop();
                vdoTrackBar.Value = 0;

            }
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.ShowDialog();
            openFileDialog1.Title = "Select video file..";
            openFileDialog1.InitialDirectory = Application.StartupPath;
            openFileDialog1.DefaultExt = ".avi";
            openFileDialog.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|All Files|*.*";
            if (openFileDialog1.FileName != "")
            {
                Form1.ActiveForm.Text = openFileDialog.FileName + " - Anand Media Player";
                vdo = new Video(openFileDialog.FileName);

                vdo.Owner = this;
                Duration = CalculateTime(vdo.Duration);
                PlayingPosition = "0:00:00";
                textStatus.Text = PlayingPosition + "/" + Duration;

                vdoTrackBar.Minimum = 0;
                vdoTrackBar.Maximum = Convert.ToInt32(vdo.Duration);
            }
        }

I'm getting the error/exception when trying to open a video file on the line:

vdo = new Video(openFileDialog.FileName);

This is the error exception i'm getting I tried to google but I didn't understand yet what should I do to fix it and i'm not using the Microsoft.DirectX.dll from the Microsoft directory in my project:

Managed Debugging Assistant 'LoaderLock' has detected a problem in 'C:\Users\bout0_000\Documents\Visual Studio 2013\Projects\DateCounter\DateCounter\bin\Debug\Battlefield1_ReleaseDateCounter.vshost.exe'.

Additional information: DLL 'C:\Windows\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

If there is a handler for this exception, the program may be safely continued.

Daniel Voit
  • 111
  • 1
  • 10
  • The managed DirectX wrappers were obsoleted 11 years ago and permanently removed from the SDK 7 years ago. The false loader lock warnings certainly contributed to their demise. Just turn the warning off. Still using them is rather unwise to put it mildly. SharpDX is a popular alternative. – Hans Passant May 08 '16 at 14:22
  • See [this post](https://blogs.msdn.microsoft.com/chuckw/2010/12/09/directx-and-net/) for a full history here and recommended replacements for the legacy Managed DirectX 1.1 assemblies. – Chuck Walbourn May 08 '16 at 21:29

0 Answers0