﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » How to Instantiate a Class a runtime from a String value</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 17:21:36 GMT</lastBuildDate><ttl>20</ttl><item><title>How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3847.aspx</link><description>I remember seeing how to do this using reflection but cannot remember how it was done. Below is psuedo code of what I want to do.&lt;/P&gt;&lt;P&gt;public sub whatever(classname as string)&lt;/P&gt;&lt;P&gt;dim something as new classname&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Paul</description><pubDate>Thu, 26 Oct 2006 15:44:02 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3881.aspx</link><description>Ivan,&lt;/P&gt;&lt;P&gt;You made me laugh :hehe: Your posts are always enjoyable to read! :)</description><pubDate>Thu, 26 Oct 2006 15:44:02 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3880.aspx</link><description>[quote][b]Paul Chase (10/26/2006)[/b][hr]Don't worry Ivan i have full faith that as soon as we get comfortable using .net MS will throw something new at us to learn.:)[/quote]&lt;/P&gt;&lt;P&gt;Should I seet and wait then?:P&lt;/P&gt;&lt;P&gt;[quote]Reflection seems like macro substitution "&amp;amp;" in foxpro but on steriods.[/quote]&lt;/P&gt;&lt;P&gt;Oh, good to know. I will certainly bump into it soon.&lt;/P&gt;&lt;P&gt;[quote]Now&amp;nbsp;I am struggling with type converters.[/quote]&lt;P&gt;Don't think you're allowed to swear in the forum!</description><pubDate>Thu, 26 Oct 2006 15:16:21 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3879.aspx</link><description>:D You have that right!!</description><pubDate>Thu, 26 Oct 2006 14:23:26 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3872.aspx</link><description>[quote]Reflection seems like macro substitution "&amp;amp;" in foxpro but on steriods.[/quote]&lt;/P&gt;&lt;P&gt;You are exactly right here...just a much better strong-typed version that is not as likely to blow your fingers off when you use it :)</description><pubDate>Thu, 26 Oct 2006 13:55:57 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3870.aspx</link><description>Don't worry Ivan i have full faith that as soon as we get comfortable using .net MS will throw something new at us to learn.:)&lt;/P&gt;&lt;P&gt;Reflection seems like macro substitution "&amp;amp;" in foxpro but on steriods.&lt;/P&gt;&lt;P&gt;Now&amp;nbsp;I am struggling with type converters.</description><pubDate>Thu, 26 Oct 2006 13:54:10 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3862.aspx</link><description>Right ... after understanding Serialization, this is my next challenge.:hehe:</description><pubDate>Thu, 26 Oct 2006 11:42:13 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3859.aspx</link><description>No problem :)&lt;/P&gt;&lt;P&gt;Reflection is fun because you can do literally ANYTHING with it... access private members, create instances of private types, etc.;&amp;nbsp;you can even use the stuff within the Emit&amp;nbsp;namespace to create&amp;nbsp;dynamic&amp;nbsp;types, methods, and assemblies.&amp;nbsp; However, you'll want to try to use it as sparingly as possible because it is slow... in fact, it's even slower than late binding, but there are times when it is unavoidable.&amp;nbsp; We go to great lengths within the framework to avoid the use of reflection where ever possible (hence the creation of the property descriptors within the business object... if you don't use them, then .NET uses reflection to accomplish all of the binding tasks).</description><pubDate>Thu, 26 Oct 2006 08:16:11 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3856.aspx</link><description>Thanks Ben,&lt;/P&gt;&lt;P&gt;That was what&amp;nbsp;I was looking for! Once I seen it the light came on. Thanks man&lt;/P&gt;&lt;P&gt;Paul&amp;nbsp;</description><pubDate>Thu, 26 Oct 2006 07:48:22 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: How to Instantiate a Class a runtime from a String value</title><link>http://forum.strataframe.net/FindPost3849.aspx</link><description>Here ya go... If you end up doing a lot of reflection, you'll probably want to import System.Reflection...&lt;/P&gt;&lt;P&gt;Private Sub DoSomething(ByVal ClassName As String, ByVal MethodName As String)&lt;BR&gt;&amp;nbsp;'-- Establish locals&lt;BR&gt;&amp;nbsp;Dim loObject As Object&lt;BR&gt;&amp;nbsp;Dim loType As Type&lt;BR&gt;&amp;nbsp;Dim loMethod As Reflection.MethodInfo&lt;/P&gt;&lt;P&gt;&amp;nbsp;'-- Get the type&lt;BR&gt;&amp;nbsp;loType = Type.GetType(ClassName)&lt;/P&gt;&lt;P&gt;&amp;nbsp;'-- Create the object&lt;BR&gt;&amp;nbsp;loObject = Activator.CreateInstance(loType)&lt;/P&gt;&lt;P&gt;&amp;nbsp;'-- Get the method&lt;BR&gt;&amp;nbsp;loMethod = loType.GetMethod(MethodName)&lt;/P&gt;&lt;P&gt;&amp;nbsp;'-- Execute the method&lt;BR&gt;&amp;nbsp;loMethod.Invoke(loObject, Nothing)&lt;BR&gt;End Sub&lt;/P&gt;&lt;P&gt;You can also use the Object Browser in visual studio and look at everything in the System.Reflection namespace.&amp;nbsp; You'll get lots of ideas of what you might want to do :)</description><pubDate>Wed, 25 Oct 2006 16:13:51 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>