Reputation: 3624
I got the following code that generates a DLL :
public class MyObject : DependencyObject
{
}
public class Timer : DependencyObject
{
}
public class AnotherClass
{
}
public class Test
{
public static void Main()
{
MyObject q1 = new MyObject();
MyObject q2 = new MyObject();
MyObject q3 = new MyObject();
MyObject q4 = new MyObject();
Timer t1 = new Timer();
Timer t2 = new Timer();
Timer t3 = new Timer();
AnotherClass a1 = new AnotherClass();
AnotherClass a2 = new AnotherClass();
AnotherClass a3 = new AnotherClass();
}
}
Then I'd like to extract instances from my DLL file. Here is what I got for the moment :
var library = Assembly.LoadFrom(libraryPath);
But then, I havent any idea about how to extract my 10 instances (4 MyObjects, 3 Timers & 3 AnotherClasses). The only thing I managed to get is the 4 classes (MyObject, Timer, AnotherClass and Test) with the code :
IEnumerable<Type> types = library.GetTypes();
but I think this is not the way I'll get my 10 instances...
(ps : I'm not even sure that the 10 instances are contained in my DLL file...)
Upvotes: 1
Views: 128
Reputation: 888047
Your question doesn't make any sense.
Those instances only exist as you execute Main()
.
If Main()
contains a loop that depends on user input, what would you want to get?
Upvotes: 4