Reputation: 10509
I have a data access provider class defined as: (this is only a part of a class relevant to my question)
public class OraDbTerminalStorage : OraDbStorage, ITerminalStorage
{
private OraDbTerminalStorage(string connString)
: base(new OraDbBroker(connString))
{
}
}
When I try to use Activator.CreateInstance like this:
Type storageType = Type.GetType(System.Configuration.ConfigurationManager.AppSettings["StorageType"],true);
var storageToUse = (ITerminalStorage)Activator.CreateInstance(storageType, string.Empty);
I get {"Constructor on type 'UZTerminal.Core.Data.OraDbTerminalStorage' not found."} MissingMethodException.
I want to instantiate a data provider with an empty connection string. I will set it further in code.
Please advise on how to get rid of the exception.
Upvotes: 1
Views: 1047
Reputation: 144112
The ctor is private. By default, Activator.CreateInstance only scans for public ctors.
Upvotes: 2