What about one of these method of Activator:

public static ObjectHandle CreateInstance(
   string assemblyName,
   string typeName,
   object[] activationAttributes
);

or

public static object CreateInstance(
   Type type,
   object[] args
);

where the array let you pass arguments to the constructor of the object you
want to instantiate.

I you use the second one, you can first get the Type by reflection based on
the name of the class expressed as a string (with the method GetType of the
Assembly class). 

Would that be useful for what you want to do?

Jerome

> -----Message d'origine-----
> De : Moderated discussion of advanced .NET topics. [mailto:ADVANCED-
> [EMAIL PROTECTED] De la part de Doug Ransom
> Envoyé : mardi 17 juin 2003 00:03
> À : [EMAIL PROTECTED]
> Objet : [ADVANCED-DOTNET] Constructing Objects From Strings in dotnet
> 
> The COM platform provided the moniker mechanism to create objects in a
> certain fashion and initialize those objects a certain way.  This was
> quite convenient when representing the object specification as a string.
> 
> If I want a user to be able to configure a .net object construction, how
> would I go about this.
> 
> For example the string "object:foo.bar!r=6" is equivelent to the C# code:
> 
> int r=6;
> new foo.bar(r);
> 
> and I would like to create or get a reference to the object by calling
> something analagous to
> GetObject("object:foo.bar!r=6");
> 
> 
> Creating the class dynamically doesn't seem to be a problem with the
> Activator methods, but what can be used to turn the intializer string into
> constructor arguments?
> 
> 
> 
> Doug Ransom
> Software Interoperability Architect
> Power Measurement
> 2195 Keating X Road
> Saanichton, BC, Canada  V8M 2A5
> Tel: 1-(250) 652-7100
> E-Mail: <mailto:[EMAIL PROTECTED]>
> Website: <http://www.pwrm.com/>
> 
> ION(r)  smart energy everywhere(tm)

Reply via email to