.NET Reflection - Getting the Assembly object instance to a Referenced Assembly
I have a solution called StoreExample
It has one web project - StoreExample.Web It has one class library StoreExample.CoreWeb has a reference to Core. What is the proper way to get an asse开发者_如何学运维mbly reference to StoreExample.Core so I can loop over the classes in StoreExample? It seems like in LoadAssembly() method call I have to know the path to the assembly. Should I have to? If so what is the standard line of code for this? If not, what is the correct way to do it?
You should be able to use System.Reflection.Assembly.GetAssembly() as shown below:
Assembly.GetAssembly(typeof(StoreExample.Core.SomeClassInCore));
Here's a better answer if you are working with assemblies that are loaded at run time and whose type is not known at compile time. A good real-life example of this is loading 3rd party plugin modules.
http://msdn.microsoft.com/en-us/library/x4cw969y.aspx
精彩评论