2

Добавил Microsoft.DirectX.AudioVideoPlayback.dll в ссылки в проекте. При попытке выбрать файл, сразу выбрасывает исключение:

System.IO.FileLoadException: "Не удалось загрузить файл или сборку "Microsoft.DirectX.AudioVideoPlayback.dll" либо одну из их зависимостей. Произошел сбой в программе инициализации библиотеки динамической компоновки (DLL). (Исключение из HRESULT: 0x8007045A)"

Вот код:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.DirectX.AudioVideoPlayback;

namespace AudioMax
{
    public partial class Form1 : Form
    {
        Audio audio;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "Media Files|*.wav;*.mp3;*.wma|All Files|*.*";
        }

        private void playButton_Click(object sender, EventArgs e)
        {
            audio.Play();
        }

        private void ejectButton_Click(object sender, EventArgs e)
        {
            if(openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                audio = new Audio(openFileDialog1.FileName);
            }
        }
    }
}

Вот подробности:

System.IO.FileLoadException
  HResult=0x8007045A
  Сообщение = Не удалось загрузить файл или сборку "Microsoft.DirectX.AudioVideoPlayback.dll" либо одну из их зависимостей. Произошел сбой в программе инициализации библиотеки динамической компоновки (DLL). (Исключение из HRESULT: 0x8007045A)
  Источник = AudioMax
  Трассировка стека:
   в AudioMax.Form1.ejectButton_Click(Object sender, EventArgs e) в C:\Users\YMS21\source\repos\AudioMax\AudioMax\Form1.cs:строка 39
   в System.Windows.Forms.Control.OnClick(EventArgs e)
   в System.Windows.Forms.Button.OnClick(EventArgs e)
   в System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   в System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   в System.Windows.Forms.Control.WndProc(Message& m)
   в System.Windows.Forms.ButtonBase.WndProc(Message& m)
   в System.Windows.Forms.Button.WndProc(Message& m)
   в System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   в System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   в System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   в System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   в System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   в System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   в System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   в System.Windows.Forms.Application.Run(Form mainForm)
   в AudioMax.Program.Main() в C:\Users\YMS21\source\repos\AudioMax\AudioMax\Program.cs:строка 19

На 19 строке ругается:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AudioMax
{
    static class Program
    {
        /// <summary>
        /// Главная точка входа для приложения.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
2
  • А вы ссылку на эту dll добавляли в проект или только в using прописали?
    – Bulson
    16 мар 2018 в 20:35
  • @Bulson он бы не запустил приложение 16 мар 2018 в 20:44

1 ответ 1

1

Обычно FileLoadException, в контексте загрузки зависимостей, возникает в следствии отсутствии этих зависимости по всем путям поиска заканчивая GAC. Так же, это может быть следствием того, что загружаемая зависимость могла не загрузить некоторую неуправляемую сборку, в вашем случае из пакета DirectX. Следовательно,

  1. Попробуйте собрать ваше приложение в x86/x64
  2. Попробуйте поставить последнюю версию DirectX
  3. Попробуйте диагностировать откуда CLR пытается загрузить сборку и проверьте пути

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.