开发者

Activator.CreateInstance is unable to find a constructor

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.OraDbTerminalS开发者_StackOverflow中文版torage' 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.


The ctor is private. By default, Activator.CreateInstance only scans for public ctors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜