I have multiple projects in a given solution.
From ProjectA I pass “myProjectB.dll” as assemblyname to a method call
in ProjectC.
When I execute the following in ProjectC, where assemblyname is “myProjectB.dll”
Assembly assembly = Assembly.LoadFrom(assemblyname);
foreach (Type type in assembly.GetTypes())
{
... my code ...
}
I get the following error
Could not load file or assembly 'file:///C:\MyProjectB\bin\Debug\myProjectB.dll' or one of its dependencies. The system cannot find the file specified.
Please let me know how to pass in the assemblyname properly into Assembly.LoadFrom method call.
How can I provide only the project DLL name and be able to go through the solution and identify the full absolute path for that DLL in the solution at run time. Is it even possible?
Thanks
If the assembly is not located in the exact path as your executable, or in the GAC, you need to give the full path in the LoadFrom method.
For example:
You can also use relative paths: