问题
How to use C# Code to List all Namespaces in .NetStandard Library 2.0 from within a .Net Standard Project.
This is the Code which gives Namspaces in netStandard Library is 0;
foreach (AssemblyName fooAssemblyName in Assembly.GetExecutingAssembly().GetReferencedAssemblies())
{
Assembly assembly = Assembly.Load(fooAssemblyName.FullName);
var namespaces = assembly.GetTypes()
.Select(t => t.Namespace).Where(t => !string.IsNullOrEmpty(t))
.Distinct();
int count = namespaces.Count();
if (fooAssemblyName.Name == "netstandard")
{
Console.WriteLine(count); // THIS GIVES 0 for .Net Standard Library
}
}
来源:https://stackoverflow.com/questions/59026604/how-to-use-c-sharp-code-to-list-all-namespaces-in-netstandard-library-in-a-net