I think Steve made 2 wrong assumptions:
1) that the project namespace must be part of the name of the compilation library.
2) that the name of the compilation library matches the name of the binary file.
At first you are mistaken when you change it in the project settings. The second one is incorrect if you specify it in buildOptions in project.json.
So your idea is correct, but the implementation is wrong. To fix this, we need to forget about resolving the namespace before loading the assembly.
I think since all assemblies will be loaded anyway, we wonβt get a big performance delay.
But this is not a panacea ... an assembly can have multiple root namespaces inside! Therefore, it is best to define an attribute at the assembly level and test it instead of the namespace.
In any case, if you want to limit the search by assembly name, this should be done as follows:
IEnumerable<AssemblyName> names = DependencyContext.Default.GetDefaultAssemblyNames(); foreach (AssemblyName name in names) { if (name.Name.StartsWith("MyRoot") == true) { Assembly assembly = Assembly.Load(name);
Maxim
source share