Mensaje
De
06/04/2010 08:10:32
 
 
a
06/04/2010 06:46:55
Vladimir Zhuravlev
Institute of the Physics of Earth,Russia
Moscow Region, Russia
General information
Foro:
ASP.NET
Category:
Miscellaneous
ID de la conversación:
01458885
ID del mensaje:
01458893
Views:
53
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
	{
	}
}
Gregory
Previous
Next
Responder
Mapa
Ver