具有固定名称 'Devart.Data.PostgreSql' 的提供程序未在机器或应用程序配置文件中注册,或者无法加载

provider with invariant name 'Devart.Data.PostgreSql' is either not registered in the machine or application config file, or could not be loaded

我在将 API 与 PostGres 数据库一起使用时收到此错误消息。

"The ADO.NET provider with invariant name 'Devart.Data.PostgreSql' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details."

我觉得我需要在我的暂存和生产服务器上安装 Devart 产品来修复错误。这样对吗?如果这是对的,我想了解为什么仅仅复制或发布 Devart dll 是不够的?正常应该够了。

在错误消息中我可以阅读 "is either not registered"。注册是什么意思?它是在 confi 文件中重新注册,还是我需要在我的暂存和生产机器上执行特定操作?

您应该在 *.config 文件的 DbProviderFactories 部分注册配置信息:

<system.data>
  <DbProviderFactories>
    <remove invariant="Devart.Data.PostgreSql" />
    <add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql" description="Devart dotConnect for PostgreSQL" type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql, Version=7.12.1328.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
  </DbProviderFactories>
</system.data>

将此处的 7.12.1328.0 替换为您的实际版本。

参考https://www.devart.com/dotconnect/postgresql/docs/?deployment.html.