mardi 13 décembre 2022

Why doesn't .NET find an assembly?

I am developing a .NET application (using C#). It uses reflection, including class System.Reflection.Assembly.

I have a .dll assembly in a file (the path is known), and I want to load it into Assembly. I use this code:

using System.Reflection;

// ...

var assembly = Assembly.LoadFile("AssemblyPath");

But it just doesn't find the assembly, despite the fact that it exists. The exception was of type System.IO.FileNotFoundException, and here's its message:

Could not load file or assembly 'C:\Users\Вова\source\repos\StreamingTest\bin\Debug\net7.0-windows10.0.22621.0\AForge.Video.FFMPEG.dll'. The specified module was not found.

What I have tried

  1. I ran this line. It wrote True.
Console.WriteLine(File.Exists("AssemblyPath"));
  1. I tried using Assembly.Load instead of Assembly.LoadFile. Exception was the same.

  2. Didn't find any answers neither on Stack Overflow, nor in the Internet.





Aucun commentaire:

Enregistrer un commentaire