Microsoft.Practices.EnterpriseLibrary.Data 创建数据库错误

Microsoft.Practices.EnterpriseLibrary.Data CreateDatabase error

我的公司从另一家已经关闭的公司那里得到了一个项目。我们现在需要的只是将连接字符串更改为我们的数据库,这与 prodaction 数据库完全相似。我将服务器地址更改为我们的,数据库名称和密码保持不变。我编译运行,创建/连接数据库时出错

public void InitDatabase(string dbName)
{
   _databaseObject = dbName == null
        ? MEL.DatabaseFactory.CreateDatabase()
        : MEL.DatabaseFactory.CreateDatabase(dbConnectionString);
}

如果输入的是空字符串,则默认连接到数据库,否则连接到指定的数据库。

当我启动它时,出现错误。

Microsoft.Practices.ServiceLocation.ActivationException: "Activation error occured while trying to get instance of type Database, key """

Inner exception #1:

ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value. At the time of the exception, the container was: Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)

Inner exception #2:

InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value.

它说“您必须配置容器”。但是没人知道怎么做。

我找到的所有解决方案都没有帮助,或者非常陈旧,大约在 2007-2012 年。在我之前已经有 3 个开发人员处理过这个问题,但是没有人设法解决这个问题。该代码绝对有效,因为该程序的类似构建可在服务器上运行。不同之处仅在于设置文件,它仅在服务器与数据库的地址上有所不同。由于 NDA,我无法上传配置文件,但如果需要其中的某些部分,我可以显示该文件的大致视图。

使用所有附加参数重新安装了 Npgsql。