<p>Using reflection, I need to investigate a user DLL and create an object of a class in it.</p>

<p>What is the simple way of doing it?</p>

[{'answer_id': 53651, 'author': 'jfs', 'author_id': 718, 'author_profile': 'https://Stackoverflow.com/users/718', 'pm_score': 5, 'selected': True, 'text': '<p>Try <a href="http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx" rel="noreferrer">Activator.CreateInstance</a>. </p>\n'}, {'answer_id': 53654, 'author': 'Nir', 'author_id': 3509, 'author_profile': 'https://Stackoverflow.com/users/3509', 'pm_score': 1, 'selected': False, 'text': '<p>You can create an instance of a class from a Type object using Activator.CreateInstance, to get all types in a dll you can use Assembly.GetTypes</p>\n'}, {'answer_id': 53655, 'author': 'Mark Ingram', 'author_id': 986, 'author_profile': 'https://Stackoverflow.com/users/986', 'pm_score': 1, 'selected': False, 'text': '<p>Take a look at these links:</p>\n\n<p><a href="http://www.java2s.com/Code/CSharp/Development-Class/Createanobjectusingreflection.htm" rel="nofollow noreferrer">http://www.java2s.com/Code/CSharp/Development-Class/Createanobjectusingreflection.htm</a></p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/k3a58006.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/k3a58006.aspx</a></p>\n\n<p>You basically use reflection to load an assembly, then find a type you\'re interested in. Once you have the type, you can ask to find it\'s constructors or other methods / properties. Once you have the constructor, you can invoke it. Easy!</p>\n'}, {'answer_id': 53658, 'author': 'samjudson', 'author_id': 1908, 'author_profile': 'https://Stackoverflow.com/users/1908', 'pm_score': 2, 'selected': False, 'text': '<p><code>System.Reflection.Assembly</code> is the class you will want to use. It contains many method for iterating over the types contained with a user DLL. You can iterate through each class, perhaps see if it inherits from a particular interface etc.</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly_members.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.reflection.assembly_members.aspx</a></p>\n\n<p>Investigate <code>Assembly.GetTypes()</code> method for getting the list of types, or <code>Assembly.GetExportedTypes()</code> for the public ones only.</p>\n'}, {'answer_id': 53679, 'author': 'Martin Marconcini', 'author_id': 2684, 'author_profile': 'https://Stackoverflow.com/users/2684', 'pm_score': 1, 'selected': False, 'text': '<p>As it has already been said, you need to poke the System.Reflection namespace. </p>\n\n<p>If you know in advance the location/name of the DLL you want to load, you need to iterate through the Assembly.GetTypes().</p>\n\n<p>In Pseudocode it would look something like this:</p>\n\n<p>Create and assembly object. </p>\n\n<p>Iterate through all the types contained in the assembly. </p>\n\n<p>Once you find the one you are looking for, invoke it (CreateInstance)… </p>\n\n<p>Use it wisely.</p>\n\n<p>;)</p>\n\n<p>I have plenty of Reflection code if you want to take a look around, but the task is really simple and there are at least a dozen of articles with samples out there in the wild. (Aka Google). \nDespite that, the MSDN is your friend for Reflection Reference. </p>\n'}]
['https://Stackoverflow.com/questions/53649', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/195/']