❔ System.Reflection

So I got a dll file that contains a class and its interface. What I want is to extract the class as an item than an instance. So for example, if I have a dynamic variable of name "temp" and I wish to put the class which I extracted from dll by looping over GetExportedTypes() of the particular Assembly and putting value into "temp" when I get the preferred class, I want to be able to use it like temp instance_of_clas = new temp(); like that, is that possible? if so, how to do it? if not, is there any alternative method (other than using Activator.CreateInstance()). My aim is not to get the instance, my aim is to get the class in such a way that I can create an instance using it.
5 Replies
mtreit
mtreit2y ago
That sounds like exactly what Activator.CreateInstance is for
infernus8349
infernus8349OP2y ago
i konw we can create an intance, thats not what i meant tahts now what i want at all i said i want a variable which i can use it like the class name like exactly like that not creating an instance my main aim is to use it for inheritance of a class i am going to create so like
public class my_class : class_got_from_reflection
{

}
public class my_class : class_got_from_reflection
{

}
mtreit
mtreit2y ago
That's not how reflection works. Inheritance is a compile time concept. Reflection is a runtime concept.
infernus8349
infernus8349OP2y ago
i see, so icannot do anything like that sort Thanks for that information, i was trying to figure that out for past 4 hours so is it possible to like get all the methods and its body of a class and put it in a txt file? is that possible
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server