加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何获取程序集的名称空间而不是其依赖项?

发布时间:2020-12-16 01:27:28 所属栏目:百科 来源:网络整理
导读:如何获取程序集的名称空间而不是其依赖项? 例如,如果我使用命名空间 assembly.GetTypes().Select(t = t.Namespace).Where(n = n != null).Distinct() 我不会得到该程序集的依赖项的命名空间吗? 我如何区分2? 我通过Assembly.LoadFrom(路径)加载程序集,我
如何获取程序集的名称空间而不是其依赖项?

例如,如果我使用命名空间

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读