Create Instance of an Interface
Posted on 2005-02-25
I thought this would be easy :) And it probably is, but I've searched and can't find anything...
Isn't there an equivalent for "getClassForName" from Java?
I have an interface, but don't know what specific class I want to load until runtime. Sure you've heard this before. I want to grab the string of the name from the Web.config file and dynamically create a class of that type...
public static IServiceProvider GetServiceProvider()
if (serviceProvider == null)
String ServiceProviderObjectName = GlobalConfigurations.ServiceProviderType;
serviceProvider = (IServiceProvider)Activator.CreateInstance(null,ServiceProviderObjectName );
return serviceProvider ;
What am I missing? And if it's all that stuff about assemblies, etc. Could someone give me the 2 minute drill on what that stuff is...:)