Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem getting assemblies list outside class dll
Message
From
06/04/2010 08:36:50
 
 
To
06/04/2010 08:10:32
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01458885
Message ID:
01458899
Views:
38
>Vlad,
>
>I don't know whether this will help you
>
>
>using System.Collections.Generic;
>using System.Reflection;
>using System.Diagnostics;
>
>
>namespace BaseTest
>{
>	class test3
>	{
>
>		//______________________________________________________________________
>		static void Main()
>		{
>
>
>			var xx = new MyClass();
>			var list = GetAllAssemblies(xx);
>
>			foreach ( var a in list )
>			{
>				Console.WriteLine("{0}", a);
>			}
>			Console.ReadLine();
>		}
>		//______________________________________________________________________
>		public static HashSet<String> GetAllAssemblies(object o)
>		{
>			var set = new HashSet<String>();
>
>			var asm = Assembly.GetAssembly(o.GetType());
>
>			Queue<String> toProcess = new Queue<String>();
>			toProcess.Enqueue(asm.FullName);
>
>			while (toProcess.Count != 0)
>			{
>				var asmName = toProcess.Dequeue();
>
>				if (set.Contains(asmName))
>				{
>
>					continue;
>				}
>
>				set.Add(asmName);
>
>
>				var asmLoaded = Assembly.Load(asmName);
>
>				var referencedAssemblies = asmLoaded.GetReferencedAssemblies();
>
>				foreach (var xx in referencedAssemblies)
>					toProcess.Enqueue(xx.FullName);
>	
>			}
>			
>
>			return set;
>		}
>		//______________________________________________________________________
>		
>	}
>	//______________________________________________________________________
>	class MyClass
>	{
>	}
>}
>
Nice Queue :-}
But isn't it likely that some assemblies will be repeated ?
UPDATE : Should have read the code properly :-{
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform