Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.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/4/postgresql/9.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.TypeMapping.GlobalTypeMapper';抛出异常_.net_Postgresql_Visual Studio_Dll_Npgsql - Fatal编程技术网

.net '的类型初始值设定项;Npgsql.TypeMapping.GlobalTypeMapper';抛出异常

.net '的类型初始值设定项;Npgsql.TypeMapping.GlobalTypeMapper';抛出异常,.net,postgresql,visual-studio,dll,npgsql,.net,Postgresql,Visual Studio,Dll,Npgsql,使用Visual Studio 2017尝试使用服务器资源管理器添加到Postgres数据库的连接。单击测试连接。显示错误的问题:Npgsql.TypeMapping.GlobalTypeMapper的类型初始值设定项引发异常 在此之前,我安装了System.Runtime.CompilerServices.Unsafe v4.5.2和System.Numerics.Vectors v4.4.0以修复错误消息“无法加载文件或程序集'System.Runtime.CompilerServices.

使用Visual Studio 2017尝试使用服务器资源管理器添加到Postgres数据库的连接。单击测试连接。显示错误的问题:Npgsql.TypeMapping.GlobalTypeMapper的类型初始值设定项引发异常

在此之前,我安装了System.Runtime.CompilerServices.Unsafe v4.5.2和System.Numerics.Vectors v4.4.0以修复错误消息“无法加载文件或程序集'System.Runtime.CompilerServices.Unsafe,版本=4.0.4.1”,并且无法加载文件或程序集'System.Numerics.Vectors,版本=4.1.3.0”

“Npgsql.TypeMapping.GlobalTypeMapper”的类型初始值设定项引发了一个异常

我只想将PostgreSQL数据库的连接添加到Visual Studio 2017。我已经有一个数据库在postgres。。。我不知道我要先安装什么来添加连接

在Visual Studio=>Tools=>Extension and update中安装了Npgsql PostgresSQL集成之后,我创建了一个新项目,直接管理Nuget软件包,并安装了System.Runtime.CompilerServices.Unsafe v4.5.2和System.Numerics.Vectors v4.4.0。 我直接尝试在服务器资源管理器中添加连接。 我对此一无所知。我只想在visual studio中添加postgres的数据连接,以便添加ADO.NET实体数据模型

进一步的技术细节 .NET framework 4.6.1
Npgsql版本4.1.1.2

我发现了一个潜在的修复方法。很难确切地理解它的作用,但它是有效的!您可以将其添加到根目录中的csproj文件中。找到这个。这似乎是一种黑客行为。不确定是否有解决问题根源的方法

<Target Name="ReplaceRefWithLib" BeforeTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <_noCopyRefs Include="@(Reference)" Condition="'%(Reference.Private)' == 'false'" />
      <_noCopyRefsByFileName Include="@(_noCopyRefs->'%(FileName)')">
        <OriginalItem>%(Identity)</OriginalItem>
      </_noCopyRefsByFileName>

      <_libByFileName Include="@(ReferenceCopyLocalPaths->'%(FileName)')">
        <OriginalItem>%(Identity)</OriginalItem>
      </_libByFileName>

      <_overlappingRefByFileName Include="@(_noCopyRefsByFileName)" Condition="'@(_noCopyRefsByFileName)' == '@(_libByFileName)' AND '%(Identity)' != ''" />
      <_overlappingLibByFileName Include="@(_libByFileName)" Condition="'@(_noCopyRefsByFileName)' == '@(_libByFileName)' AND '%(Identity)' != ''" />

      <_overlappingRef Include="@(_overlappingRefByFileName->'%(OriginalItem)')" />
      <_overlappingLib Include="@(_overlappingLibByFileName->'%(OriginalItem)')" />
    </ItemGroup>

    <ItemGroup Condition="'@(_overlappingRef)' != ''">
      <Reference Remove="@(_overlappingRef)" />
      <Reference Include="@(_overlappingLib)">
        <Private>false</Private>
      </Reference>
    </ItemGroup>
  </Target>

  <Target Name="RemoveNetFxForceConflicts" AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <ReferencePath Remove="@(ReferencePath)" Condition="'%(FileName)' == 'netfx.force.conflicts'" />
    </ItemGroup>
  </Target>

%(身份)
%(身份)
假的
。每次出现错误时,请搜索github