question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Npgsql 5.0.7 via nuget on .NET 4.8 gives MissingMethodException in ChannelReader

See original GitHub issue

Exception:

Method not found: 'System.Threading.Tasks.ValueTask`1<Boolean> System.Threading.Channels.ChannelReader`1.WaitToReadAsync(System.Threading.CancellationToken)'.

Stacktrace:

   at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<Rent>g__RentAsync|0()
   at Npgsql.ConnectorPool.Rent(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Npgsql.NpgsqlConnection.Open()
   at SD.LLBLGen.Pro.Gui.Controls.WizardPages.MetaDataRetrievalWizard_Step_ConnectionData.TestConnectionData(Boolean showSuccess) in C:\MyProjects\VS.NET Projects\LLBLGen Pro v5.9\Designer\Gui\Controls\WizardPages\MetaDataRetrievalWizard_Step_ConnectionData.cs:line 245

It’s in my driver, where I obtain the factory using NpgsqlFactory.Instance as I now directly reference the Nuget package. I compile against 4.8 (against 4.7.2 same issue). I copy all necessary files to the output folder, app using the driver is running on .net 4.8, I checked. All I do is obtaining a connection from the factory and then call Open.

I am using this route because Npgsql doesn’t ship an msi anymore so I have to reference the Npgsql package directly to make my users not have to fight where to get the files.

I have no idea what to do nor what I’m doing wrong. It looks like I have to reference another package somewhere but which one is a blur to me.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:25 (22 by maintainers)

github_iconTop GitHub Comments

4reactions
rojicommented, Jan 6, 2022

OK, took a look.

After building everything successfully, running NpgsqlRepro.exe failed with:

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Looking at the actual System.Runtime.CompilerServices.Unsafe.dll deployed in Drivers\PostgreSQL, it had a version of 6.0.0, so I amended the binding redirects. When that didn’t work, I noticed that the <dependentAssembly> directives are outside of the <assemblyBinding> node - so I moved them in. At this point the program connected, but threw another runtime binding redirect exception for System.Text.Json, after I added that everything worked…

2reactions
rojicommented, Jan 5, 2022

There already was a 6-month gap there, I’d like to make sure this gets closed this time 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Npgsql 5.0.7
Version Downloads Last updated 8.0.0‑preview.4 38,240 3 months ago 8.0.0‑preview.3 19,308 4 months ago 8.0.0‑preview.2 24,685 5 months ago
Read more >
System.MissingMethodException: Method not found?
I just ran into this on a .NET MVC project. The root cause was conflicting versions of NuGet packages. I had a solution...
Read more >
Npgsql does not work with add-ins
I have added to my add-in a nuget package for Npgsql. I am working with Pro 2.6.2 The latest verison i.e. NuGet\Install-Package Npgsql...
Read more >
Please stop lying about .NET Standard 2.0 support!
In this post I have a bit of a rant about Microsoft's NuGet packages lying about supporting .NET Standard 2.0 when they kinda...
Read more >
NuGet Error NU1100
Solution 1. Open the project file and examine the list of its dependencies. Check that each dependency exists on the package sources you're ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found