I have the current file structure in my Visual Studio project:
- MyProject/
- MyStartupProject/
- bin/
- Debug/
- Program.cs
- bin/
- DependencyProject/
- bin/
- dlls/
- MyAssembly.dll
- Code.cs
- MyStartupProject/
My Main()
function is inside MyProject/MyStartupProject/Program.cs
. Inside Code.cs
is a line var assembly = Assembly.Load("MyAssembly");
, which is supposed to load MyProject/DependencyProject/dlls/MyAssembly.dll
, but instead it causes the error
System.IO.FileNotFoundException: 'Could not load file or assembly 'MyAssembly' or one of its dependencies.
The system cannot find the file specified.'
However, everything runs perfectly fine if I copy MyAssembly.dll
into MyProject/MyStartupProject/bin/Debug
. How do I fix this reference so the project can find it under the dlls directory?