dragonbanshee dragonbanshee - 9 months ago 31
C# Question

Activator.CreateInstance missing overloads

I want to use

Activator.CreateInstance(string, string, object[])
but Visual Studio can't find it in the list of overloads. I want to create an instance of a class just by having the name of the class as a string (without having to go through a chain of if statements.

I figure it has something to do with using UWP but I'm not sure. MSDN says this overload exists (as well as many others) but my Visual Studio can only find these 3 overloads:

Activator.CreateInstance();
Activator.CreateInstance(Type);
Activator.CreateInstance(params object[]);

Answer Source

I figure it has something to do with using UWP but I'm not sure

That's correct. A good way to know which base APIs are available on UWP is to filter on "Silverlight": https://msdn.microsoft.com/en-us/library/system.activator.createinstance(v=vs.95).aspx