Closed SeppPenner closed 10 months ago
Those types don't exist https://github.com/search?q=repo%3Anpgsql%2Fnpgsql%20TypeHandlerResolverFactory%20&type=code https://github.com/search?q=repo%3Anpgsql%2Fnpgsql+TypeHandlerResolver&type=code Not sure what you're expecting here.
Those types don't exist https://github.com/search?q=repo%3Anpgsql%2Fnpgsql%20TypeHandlerResolverFactory%20&type=code https://github.com/search?q=repo%3Anpgsql%2Fnpgsql+TypeHandlerResolver&type=code Not sure what you're expecting here.
I know. And I don't know why I would need them either... After I upgraded from Net7 to Net8, the error occurs when I try to add the controllers.
What I expect? No error basically, as it's completely unclear where this comes from.
My guess is the following:
First project: (Let's call it API
) has controllers and references project 2 that has model classes.
Second project: (Let's call it Models
) has data models and references Npgsql
.
--> When adding the controller routes with .MapControllers();
, MVC somehow tries to access these type initializers. Why? No idea? Is it a bug in MVC or in Npgsql? No idea either.
I'm just looking for a fix or workaround how to handle this to be able to upgrade to Net8.
I'm guessing your second project is building with 7.0.x of npgsql and the first project is using 8.0.x of npgsql. 8.0 is being resolved when running the project and since there is a "breaking" change where those types don't exist anymore, you're getting that error. To fix it, either don't use internal types from npgsql, or update the second project to 8.0 (which will also prevent you from using the internal types).
I'm guessing your second project is building with 7.0.x of npgsql and the first project is using 8.0.x of npgsql.
Npgsql is version 8.0.1 in all projects... That was the first thing I checked yesterday after it didn't work as expected.
Can I somehow easily check if another referenced NuGet package uses Npgsql in an older version?
Do you have a NuGet package that's in your dependency tree somewhere that is compiled against the 7.0.x version? The {ProjectName}.deps.json
file in the build output should contain the whole dependency graph.
I guess, I found the issue...
Do you have a NuGet package that's in your dependency tree somewhere that is compiled against the 7.0.x version? The {ProjectName}.deps.json file in the build output should contain the whole dependency graph.
The issue is that a dependency of project 2 (aka Models
) had a dependency to another project that had a dependency to Npgsql 7.11.0 or something...
So basically, the issue is dll / dependency hell 😅
Thanks @martincostello for pointing that out.
Is there an existing issue for this?
Describe the bug
When upgrading to Net8.0 and all the latest NuGet packages, the following error occurs in the
ControllerFeatureProvider
class:The details are:
The issue occurs when calling
from the
Startup.cs
class.Expected Behavior
There have been changes in https://github.com/npgsql/npgsql/issues/5438 that seem to cause the issue (
TypeHandlerResolverFactory
andTypeHandlerResolver
is now internal). Not sure though why this is related.Steps To Reproduce
I guess, that the problem occurs if a controller contains models (e.g. as return type) that have a reference to the
Npgsql
package somehow.Exceptions (if any)
.NET Version
8.0.100
Anything else?