Convert String to type via the string
This is what I have.
String TypeName; //This is passed in from the webPage.
Type objectType = typeof(TOG.PJM.Entities.Nodes);
//Type objectType = Type.GetType(TypeName);
_objectGraph = Activator.CreateInstance(objectType);
I have two seperate projects and namespaces that seperate the Class that I'm tring to pull the type of and this method that returns the type of the class in the other project/namespace. The only thing I have is the string TypeName which contains "TOG.PJM.Entites.Nodes, TOG.PJM". You can see that I use that in the commented out line, and that's what I want, but unless I use the typeof first it acts as if it can't see the Nodes class. But if I have the typeof first, as I do here and I uncommented out that line, it would work just fine.
Sorry if this is confusing.
Thanks for any suggestions.
Why not use the overload of CreateInstance that accepts the type name as a string? http://msdn2.microsoft.com/en-us/lib...a4(VS.80).aspx
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
By Rob Teixeira in forum .NET
Last Post: 05-31-2002, 04:30 PM
By Martin in forum VB Classic
Last Post: 12-03-2001, 04:53 AM
By Julian Milano in forum VB Classic
Last Post: 08-10-2000, 10:16 PM
By Chandra in forum VB Classic
Last Post: 06-22-2000, 01:52 PM
By Robert Rieth in forum VB Classic
Last Post: 04-11-2000, 04:21 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center