Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2007

Tip: Looking for answers? Try searching our database.

Class handling fully qualified type names?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jens Weiermann - 30 Jan 2007 08:41 GMT
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
Oliver Sturm - 30 Jan 2007 16:42 GMT
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
Signature

http://www.sturmnet.org/blog


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.