0

My Solution(VS2010) has many projects.

At run time, How do I get list of all the assemblies in a given project?

I can get list of all assemblies within the calling code project by following line of code.

Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()

How do I get list of assemblies in a project different than calling code project?

Please help. Thanks

dotnet-practitioner
  • 13,968
  • 36
  • 127
  • 200
  • Check out the second part of [this answer](http://stackoverflow.com/questions/383686/how-do-you-loop-through-currently-loaded-assemblies) – Paul Phillips Jul 16 '12 at 17:12
  • Paul - If I have a project called WebApplication1 then how do I get hold of WebApplication1 assembly? How do I do this var webassembly = GetAssembly("WebApplication1"); ? Thanks – dotnet-practitioner Jul 16 '12 at 17:21
  • Find a class you know is in that assembly, say it's called `MyClass`. Then you can do `typeof(MyClass).Assembly`. If you just have the string name, look at [this answer](http://stackoverflow.com/questions/1913057/how-to-get-c-net-assembly-by-name). – Paul Phillips Jul 16 '12 at 17:24
  • Both of those answers you could have easily found by searching, by the way. Please do more research before asking a question. – Paul Phillips Jul 16 '12 at 17:26

1 Answers1

1

A solution may contain projects that are not referenced by the project you currently are executing. I don't know if there is a solid way to retrieve those.

However if your calling assembly does contain a reference to the other projects, you can walk through the myAssembly.GetReferencedAssemblies() array. Note that this will also include referenced framework assemblies.

C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72