Andy <on*********@geovap.cz> wrote:
I'm trying to dynamically create object in runtime, here is code example:
string name = "System.Xml.XmlTextWriter"; // this is in fact read from
Database
System.Type t = System.Type.GetType(name);
System.Object ob = System.Activator.CreateInstance(t);
When type name is from another namespace then System, GetType method return
null. What is wrong?
Your use of Type.GetType is wrong. As the docs say, only the current
assembly and mscorlib are searched unless you give a *full* type name
which includes the assembly name.
You either need to specify the full type name, or load/find the
appropriate assembly and call Assembly.GetType.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too