In the web.config file, we see a lot of strings following this pattern:
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup,
System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"
I want to read this information from the web.config (which I know how to read as a string), and I want to instantiate a type from this string.
Is there some way to do this?
Update
I guess I could just do
Activator.CreateInstance(System.GetType(stringTypeName))
Please confirm?
There are several overloads of
Activator.CreateInstancethat enable you to do this. However, you will have to split the string into a type name and assembly name manually.Update: Your own take on this is also correct (although the method is
Type.GetType()).