Class handling fully qualified type names?

J

Jens Weiermann

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!
Jens
 
O

Oliver Sturm

Hello Jens,
Or is there some built-in way that I just
couldn't find?

This should work fine:

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


Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top