For .NET 4.6.1, always profile your usage of Activator . If it becomes a bottleneck, replace it with compiled expression trees or a lightweight cache of constructor delegates.
Assembly plugin = Assembly.LoadFrom("MyPlugin.dll"); Type pluginType = plugin.GetType("MyPlugin.Formatter"); IPlugin instance = (IPlugin)Activator.CreateInstance(pluginType); activators dotnet 4.6.1
: This overload allows you to pass arguments to a constructor that matches the provided signature. For .NET 4.6.1
The most frequently used method is Activator.CreateInstance , which provides several overloads to handle different instantiation needs: Type pluginType = plugin.GetType("MyPlugin.Formatter")
Since .NET Framework 4.6.1 reached its , it is highly recommended to migrate to Microsoft .NET Framework 4.8.1 for better security. Guide to Using Activators in .NET 4.6.1
public MyClass()
The biggest criticism of Activator.CreateInstance is . Reflection-based instantiation can be 30–50x slower than new .