例如,如果我使用命名空间
assembly.GetTypes().Select(t => t.Namespace).Where(n => n != null).Distinct()
我不会得到该程序集的依赖项的命名空间吗?
我如何区分2?
我通过Assembly.LoadFrom(路径)加载程序集,我知道它会自动加载程序集的依赖项.对于解决方案,我是否必须以未加载依赖项的方式加载程序集?如果是的话,我该怎么做?
此外,我无法控制程序集的创建,例如添加空类等.
编辑:纠正一个例子
System.Linq.Expressions实际上是在EntityFramework.dll中.具体来说,以下类位于该命名空间下的DLL中:
> System.Linq.Expressions.EntityExpressionVisitor
> System.Linq.Expressions.Internal.Error
> System.Linq.Expressions.Internal.ReadOnlyCollectionExtensions
此外,您还应该看到System.ComponentModel.DataAnnotations,因为EntityFramework.dll定义了类System.ComponentModel.DataAnnotations.Schema.IndexAttribute.
**注意,我正在检查EntityFramework 6.0.0.0
要更直接地回答您的问题:
How do I get the namespaces of an assembly and not of its dependencies?
assembly.GetTypes().选择(t => t.Namespace)
Would I not get the namespaces of the dependencies of that assembly as well?
没有.
How do I distinguish between the 2?
N / A
For the solution, do I have to load the assembly in a way that the dependencies are not loaded?
没有.
If yes, how do I do that?
N / A