I need to generate a list of my assemblies for a project. I am using this code :
Assembly[] lstAssembly = AppDomain.CurrentDomain.GetAssemblies();
which is somehow working but It doesn't show all of my namespaces in solution. I want To know why it doesn't show all the namespace in my solution
My solution and its projects are like this:
> MySolution'TST'
>|-->BaseWinApp(Project1)
>|-->ProductWinApp(Project2)
>|-->SaleWinApp(Project3)
>|-->TST(Start Up Project)
It returns just directly referenced libraries by default. You need to load recursively if you want to load all of them.
var myrootAssembly = Assembly.GetExecutingAssembly();
var loadedPath = myrootAssembly.Location;
var rootPath = loadedPath.Substring(0, loadedPath.LastIndexOf('\\') + 1);
var referencedPaths = Directory.GetFiles(rootPath, "*.dll");
foreach (var refPath in referencedPaths)
{
assemblyList.Add(Assembly.LoadFrom(refPath));
}
您是否打算执行以下操作,以便为该程序集提供名称空间
Assembly.GetExecutingAssembly().GetTypes().Select(t => t.Namespace).ToList();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.