Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to create a type dynamically at run time, Activator.CreateInstance Method will do it for you. If you issue is with the type having a constructor with parameters, this overload will do this. For example, <a href="http://msdn.microsoft.com/en-us/library/wcxyzt4d.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/wcxyzt4d.aspx</a></p> <p>I advise looking through the overloads for the best match.</p> <p>The namespace issue should be not be relavant - as long as the dll is in the bin directory or the GAC you should be OK. The rules may change if the assembly is Strongly named though.</p> <p>Could you provide a code snippiet of the code that is not working (using the method you linked to)? This + the errors you are seeing will be very helpful! [update] Quick sample using the Activator.CreateInstance that handles Constructors w/ paramaters.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { BaseProduct b =(BaseProduct)System.Activator.CreateInstance(Type.GetType("ConsoleApplication1.Product") ,new object[]{typeof(string)}, new object[]{"123"} ); //Activator..::.CreateInstance Method (Type, array&lt;Object&gt;[]()[], array&lt;Object&gt;[]()[]) } } public class Product: BaseProduct{ public Product(string id) { } public string Id {get;set;} } public abstract class BaseProduct { abstract public string Id { get; set; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload