For example in a .NET app.config you might get
<configuration>
<configSections>
<section name="MyConfig" type="MyAssembly.MyType, MyAssembly, PublicKeyToken=null" />
</configSections>
...
</configuration>
The signature in the type part seems to be standardized in a variety of .NET places but I have no idea how to do this within my own programs. I have used System.Activator
in my programs but that feels like I'm duplicating work that .NET already does.
In programming terms how do I do this:
void Main()
{
object instance = CreateInstance("MyAssembly.MyType, MyAssembly, PublicKeyToken=null");
Console.WriteLine(instance.GetType().Name);
}
object CreateInstance(string dotNetTypeSignature)
{
// Code goes here.
}