Groups | Blog | Home
all groups > dotnet framework > january 2007 >

dotnet framework : Class handling fully qualified type names?


Jens Weiermann
1/30/2007 9:41:33 AM
Hi,

in many occasions (mainly with configuration), you'll have to specify fully
qualified type names in the format

type="Fully qualified class name, assembly file name, version, culture,
public key token"

I was suprised to see that there's no overload of
Activator.CreateInstance() that can be fed such a string directly. I also
wasn't able to find a class that would make handling fully qualified names
easy...

If I need access to the type name and the assembly name separately, do I
have to parse that string myself? Or is there some built-in way that I just
couldn't find?

Parsing the string sure is easy, but I just don't want to re-invent the
wheel if it's not necessary...

Thanks!
Oliver Sturm
1/30/2007 4:42:24 PM
Hello Jens,

[quoted text, click to view]

This should work fine:

Type type = Type.GetType("... long type string here ...");
object instance = Activator.CreateInstance(type);


Oliver Sturm
--
AddThis Social Bookmark Button