Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Npgsql v5.0.0 GAC安装_.net_Npgsql_Gac - Fatal编程技术网

.net Npgsql v5.0.0 GAC安装

.net Npgsql v5.0.0 GAC安装,.net,npgsql,gac,.net,Npgsql,Gac,正如Npgsql 5.0版发行说明(突破性更改)中所述,MSI GAC安装程序已停止使用。发行说明中的声明如下: gacutil.exe /i Npgsql.dll gacutil.exe /i Microsoft.Bcl.AsyncInterfaces.dll gacutil.exe /i System.Buffers.dll gacutil.exe /i System.Memory.dll gacutil.exe /i System.Numerics.Vecto

正如Npgsql 5.0版发行说明(突破性更改)中所述,MSI GAC安装程序已停止使用。发行说明中的声明如下:

   gacutil.exe /i Npgsql.dll
   gacutil.exe /i Microsoft.Bcl.AsyncInterfaces.dll
   gacutil.exe /i System.Buffers.dll
   gacutil.exe /i System.Memory.dll
   gacutil.exe /i System.Numerics.Vectors.dll
   gacutil.exe /i System.Runtime.CompilerServices.Unsafe.dll
   gacutil.exe /i System.Text.Encodings.Web.dll
   gacutil.exe /i System.Text.Json.dll  
   gacutil.exe /i System.Threading.Channels.dll
   gacutil.exe /i System.Threading.Tasks.Extensions.dll
   gacutil.exe /i System.ValueTuple.dll
Npgsql不再以.NETFramework 4.6.1为目标。自.NET标准2.0以来 如果有针对性,仍然可以使用.NET Framework中的Npgsql 应用;但是,我们不再在.NET上运行回归测试 框架,并且只会在尽最大努力的基础上修复bug。此外 VisualStudio扩展(VSIX)和MSI GAC安装程序已安装 停产

由于此更改,我面临的问题是,我的客户端使用MSI安装程序在GAC中安装Npgsql,我的应用程序使用.Net framework的System.Data.Common.DbProviderFactorys动态加载其工厂。这使我能够灵活地让客户机根据其数据库版本选择所需的提供程序版本

切换到nuget软件包安装将增加在我的应用程序中更新Npgsql软件包的开销。因此,我想避开这条路线。有没有办法像MSI安装程序那样在GAC中安装最新的Npgsql 5.0版本


如果是,请告诉我操作步骤。

Npgsql 5.0不再针对.NET Framework(net461TFM),只针对
netstandard2.0
TFM(以及一些较新的)。因此,无法再将其安装到GAC中


DbProviderFactorys仍然可以在没有GAC的情况下使用(使用.NET Framework或.NET Core),但是Npgsql程序集必须与应用程序一起分发,或者作为“插件”放入其目录中。

最后,我使用gacutil.exe在GAC中注册了所有程序集,使其正常工作

我在应用程序中使用.Net framework 4.6.1,并已执行以下步骤在GAC中安装Npgsql 5.0.0.0版:

  • 在新的Visual Studio项目中添加所需版本的Npgsql.Net数据提供程序的引用

  • 在文件夹中查找并复制此提供程序添加的所有程序集

  • 现在我们需要使用gacutil.exe在GAC中注册这些程序集。它可以与Visual Studio命令提示符一起使用,也可以与Windows SDK一起使用

  • 使用具有管理员权限的命令,并对每个程序集运行以下命令。 gacutil.exe/i“AssemblyPath/assemblyName.dll”

  • 对于5.0.0.0版,完整的命令列表如下所示:

       gacutil.exe /i Npgsql.dll
       gacutil.exe /i Microsoft.Bcl.AsyncInterfaces.dll
       gacutil.exe /i System.Buffers.dll
       gacutil.exe /i System.Memory.dll
       gacutil.exe /i System.Numerics.Vectors.dll
       gacutil.exe /i System.Runtime.CompilerServices.Unsafe.dll
       gacutil.exe /i System.Text.Encodings.Web.dll
       gacutil.exe /i System.Text.Json.dll  
       gacutil.exe /i System.Threading.Channels.dll
       gacutil.exe /i System.Threading.Tasks.Extensions.dll
       gacutil.exe /i System.ValueTuple.dll
    
  • 现在在machine.config文件的两个位置添加以下条目
  • 位置1:
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.Config

    位置2:
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.Config

    配置条目:

     <system.data>
            <DbProviderFactories><add name="Npgsql Data Provider" invariant="Npgsql" description=".NET Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5D8B90D52F46FDA7"/></DbProviderFactories>
     </system.data>
    
    
    
  • 在当前版本5.0.0.0中,Npgsql试图找出依赖程序集的较低版本。我认为这是一个bug,他们可能会在以后的版本中修复这个问题,但是现在我们需要在application App.confg文件中创建一些依赖程序集的条目来使用这些版本
  • YourApplication.exe.config可以在安装目录中找到,您需要在
    部分下添加以下行:

    <dependentAssembly>
    <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
    </dependentAssembly>
    
    
    

    现在,我可以轻松地在应用程序中获得DbProviderFactory实例,而不会出现任何问题。

    这是我主要关心的问题,我希望避免将Npgsql与我的应用程序捆绑在一起,否则我可以使用Nuget.AFAIK轻松地将其捆绑在一起,使用Npgsql 5.0.0,无法将其安装到GAC中。与应用程序捆绑(或允许用户以某种方式将其安装到应用程序中)是您唯一的选择。由于您是Npgsql的所有者,我必须相信没有其他方法:)很高兴知道您在这里很活跃,直接从您那里得到答案当然是值得赞赏的。非常感谢你的时间和帮助。谢谢。。。我可以肯定的是,NPGSQL5.0.0不再针对任何.NET框架,只针对TFM的.NET标准和.NET核心。我不太确定的是,是否可以在GAC中安装netstandard2.0程序集-您可以使用gacutil手动尝试-iYes我会尝试一下,再次感谢。