Added Microsoft.DirectX.AudioVideoPlayback.dll to the links in the project. When you try to select a file, immediately throws an exception:

System.IO.FileLoadException: "НС ΡƒΠ΄Π°Π»ΠΎΡΡŒ Π·Π°Π³Ρ€ΡƒΠ·ΠΈΡ‚ΡŒ Ρ„Π°ΠΉΠ» ΠΈΠ»ΠΈ сборку "Microsoft.DirectX.AudioVideoPlayback.dll" Π»ΠΈΠ±ΠΎ ΠΎΠ΄Π½Ρƒ ΠΈΠ· ΠΈΡ… зависимостСй. ΠŸΡ€ΠΎΠΈΠ·ΠΎΡˆΠ΅Π» сбой Π² ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ΅ ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ динамичСской ΠΊΠΎΠΌΠΏΠΎΠ½ΠΎΠ²ΠΊΠΈ (DLL). (Π˜ΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ΠΈΠ· HRESULT: 0x8007045A)" 

Here is the code:

 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); } } } } 

Here are the details:

 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 

On line 19 swears:

 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()); } } } 
  • Did you add a link to this dll to the project or did you just register in using? - Bulson
  • @Bulson he would not have launched the application - Artem Okonechnikov

1 answer 1

Usually FileLoadException , in the context of loading dependencies, occurs due to the absence of these dependencies across all search paths ending with the GAC. Also, this may be due to the fact that the dependency being loaded could not have loaded some unmanaged build, in your case from the DirectX package. Consequently,

  1. Try building your application in x86 / x64
  2. Try to install the latest version of DirectX.
  3. Try to diagnose where the CLR is trying to load the assembly and check the paths