Question

I am trying to open PostgreSQL connection but getting ReflectionTypeLoadException while opening connection.

Please help me out to solve this problem by providing code or let me know how to remove this exception.

Code i am using so far is below:

  **/* Connection String 
   <?xml version="1.0" encoding="utf-8" ?>
   <configuration>
      <appSettings>
        <add key="superuserDatabase" value="postgres"/>
      </appSettings>
      <system.data>
      <DbProviderFactories>
        <clear/>
         <add name="Npgsql Data Provider"
           invariant="Npgsql"
           description=".Net Framework Data Provider for Postgresql Server"
            type="Npgsql.NpgsqlFactory, Npgsql" />
      </DbProviderFactories>
     </system.data>
     <connectionStrings>
       <add name="Simple.Data.Properties.Settings.DefaultConnectionString"
          connectionString="host=localhost;port=5432;database=SimpleData;user                                                                     id=postgres;password=P@ssw0rdsa;pooling=false"
           providerName="Npgsql" />
    <add name="Test"
          connectionString="host=localhost;port=5432;database=SimpleData;user    id=postgres;password=P@ssw0rdsa;pooling=false"
          providerName="Npgsql" />
     </connectionStrings>
   </configuration>**
   */

I am getting following exception when trying to open connection in POSTGRESQL var namedDb = Database.OpenNamedConnection("Test").Demo.All();

ReflectionTypeLoadException

Était-ce utile?

La solution

This ReflectionLoadTypeException is most often caused because the DLLs you're using aren't up to date so the dependency chain fails. Use nuget to update your project with the latest DLLs. v0.16.2.2 of the PostgreSql provider requires

  • Simple.Data.Core (≥ 0.12.2.2)
  • Simple.Data.Ado (≥ 0.12.2.2)
  • Npgsql (≥ 2.0.11)

(via Mark Rendle) Try explicitly installing 0.16.2.2 of Simple.Data.Ado first, then installing the Postgres package.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top