lundi 27 août 2018

How do I get the namespaces of an assembly and not its dependencies?

How do I get the namespaces of an assembly and not of its dependencies?

For example, if I get the namespaces in EntityFramework.dll using

assembly.GetTypes().Select(t => t.Namespace).Where(n => n != null).Distinct() 

and then only list the namespaces with the minimum periods, I get the following two namespaces

System.Data.Entity
System.Linq.Expressions

However, System.Linq.Expressions is the namespace of an assembly that EntityFramework.dll is dependent on and not a namespace of EntityFramework.dll, which clearly is System.Data.Entity.

How do I distinguish between the 2?

I am loading the assembly via Assembly.LoadFrom(path) and I understand that it automatically loads the assembly's dependencies. 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?

Also, I do not have any control over the Assembly creation, like adding an empty class etc.





Aucun commentaire:

Enregistrer un commentaire