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:10:32
 
 
To
06/04/2010 06:46:55
Vladimir Zhuravlev
Institute of the Physics of Earth,Russia
Moscow Region, Russia
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01458885
Message ID:
01458893
Views:
51
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
Reply
Map
View

Click here to load this message in the networking platform