Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'DisposeAsync' method of type 'Npgsql.NpgsqlBinaryExporter' has no implementation. #3049

Closed
Rodriguevb opened this issue Jul 2, 2020 · 3 comments

Comments

@Rodriguevb
Copy link

The simple stupid error but I can't find any solution on internet.
I get a error with a simple project .NETFramework v4.6.1 with NuGet PackageReference.
Did I forget a specific reference?

Rider Database works well:
DBMS: PostgreSQL (ver. 12.3)
Case sensitivity: plain=lower, delimited=exact
Driver: PostgreSQL JDBC Driver (ver. 42.2.5, JDBC4.2)
Ping: 15 ms
SSL: no

The simple code in the test method:

var host = "localhost";
var port = 5432
var database = "postgres";
var username = "postgres";
var password = "password";
var connectionString = $"Host={host};Port={port};Database={database};Username={username};Password={password};";
var connection = new NpgsqlConnection(connectionString);
try
{
	connection.Open();
}
catch (Exception ex)
{
	var rtle = ex.InnerException as ReflectionTypeLoadException;
	var exceptions = rtle.LoaderExceptions;
	//  ^^^^^^^^^^
	// list of 2items:  System.TypeLoadException: The 'DisposeAsync' method of type 'Npgsql.NpgsqlBinaryExporter' of assembly 'Npgsql, Version=4.1.3.1, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' has no implementation.
}

All PackageReference in the project.csproj:

<PackageReference Include="Npgsql" Version="4.1.3.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.abstractions" Version="2.0.0" />
<PackageReference Include="xunit.assert" Version="2.1.0" />
<PackageReference Include="xunit.core" Version="2.1.0" />
<PackageReference Include="xunit.extensibility.core" Version="2.1.0" />
<PackageReference Include="xunit.extensibility.execution" Version="2.1.0" />

The exception:

System.TypeInitializationException: Une exception a été levée par l'initialiseur de type pour 'Npgsql.TypeMapping.GlobalTypeMapper'. ---> System.Reflection.ReflectionTypeLoadException: Impossible de charger un ou plusieurs des types requis. Extrayez la propriété LoaderExceptions pour plus d'informations.
   à System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   à System.Reflection.RuntimeModule.GetTypes()
   à System.Reflection.Assembly.GetTypes()
   à Npgsql.TypeMapping.GlobalTypeMapper.SetupGlobalTypeMapper() dans C:\projects\npgsql\src\Npgsql\TypeMapping\GlobalTypeMapper.cs:ligne 161
   à Npgsql.TypeMapping.GlobalTypeMapper..cctor() dans C:\projects\npgsql\src\Npgsql\TypeMapping\GlobalTypeMapper.cs:ligne 32
   --- Fin de la trace de la pile d'exception interne ---
   à Npgsql.TypeMapping.GlobalTypeMapper.get_Instance()
   à Npgsql.TypeMapping.ConnectorTypeMapper..ctor(NpgsqlConnector connector) dans C:\projects\npgsql\src\Npgsql\TypeMapping\ConnectorTypeMapper.cs:ligne 60
   à Npgsql.NpgsqlConnector.<LoadDatabaseInfo>d__149.MoveNext() dans C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:ligne 431
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   à Npgsql.NpgsqlConnector.<Open>d__148.MoveNext() dans C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:ligne 423
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   à Npgsql.ConnectorPool.<AllocateLong>d__28.MoveNext() dans C:\projects\npgsql\src\Npgsql\ConnectorPool.cs:ligne 249
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   à System.Threading.Tasks.ValueTask`1.get_Result()
   à System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
   à Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<<Open>g__OpenLong|0>d.MoveNext() dans C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:ligne 297
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   à System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   à Npgsql.NpgsqlConnection.Open() dans C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:ligne 119
   à Postgresql.Tests.Queries.Test() dans C:\Git\Postgresql.Tests\Queries.cs:ligne 20
@mgravell
Copy link

mgravell commented Jul 2, 2020

what is confusing me is that the <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" /> reference (needed for IAsyncDisposable) was only added last month, but 4.1.3.1 is 4 months old ... so ... 😕

@mgravell
Copy link

mgravell commented Jul 2, 2020

ah, duplicate: #2923 - there is some guidance in that other post, but the "real fix" kinda needs that addition. You could try adding the missing package reference locally, and hoping?

@Rodriguevb
Copy link
Author

  • Add <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" />
  • Clean solution
  • Delete the obj/ folder
  • Build
  • Crying with joy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants