-
Notifications
You must be signed in to change notification settings - Fork 225
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 type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception. #32
Comments
From @BeranekCZ on November 19, 2015 21:11 I have same problem. On Windows is everything ok but on Linux I get this exception too. |
From @bdimag on November 21, 2015 10:19 I am getting this as well on Docker (microsoft/aspnet:1.0.0-rc1-final-coreclr) after e.g.,
|
From @damageboy on November 23, 2015 19:59 @bdimage Hmm, Npgsql provides the postgres inet types. As part of this it needs classes coming in from the System.Net.NetworkInformation namespace, which also comes from the System.Net.NetworkInformation nuget/dll in CoreCLR. Let me try and recreate this with the microsoft docker image and see what System.Net.NetworkInformation.dll I have when running under that runtime + docker image |
From @bdimag on November 25, 2015 3:29 @damageboy I had it working in beta8 -- same code and environment (except |
From @sirentek on November 25, 2015 5:33 @bdimag You had it working in beta8 ? Does your project run without any exception ? Could you provide your project.json file for the versions you have used ? |
From @bdimag on November 25, 2015 8:0 project.txt Will have to try and recreate for beta8 -- that is lost. |
From @bdimag on November 26, 2015 3:25 @sirentek No exceptions, creates a db, table and record |
From @barhun on December 6, 2015 1:28 It was working in beta8, regardless of the runtime (running successfully on both mono and coreclr). After switching the version of the runtime to rc1-final or to rc1-update1 and using the nuget packages EntityFramework7.Npgsql rc1-final-1 or rc1-final-2, there have occurred issues dependent on the runtime. When using coreclr, the stack trace is as follows:
Using mono runtime, it relates to some native call:
|
From @kpocza on December 6, 2015 12:20 I was facing the same Mono (v. 4.2.1) issue in Npgsql that @barhun mentioned. It seems to me that ConcurrentDictionary on Mono cannot be cast to IReadOnlyDictionary this way: internal static IReadOnlyDictionary<string, TypeHandler> GlobalCompositeMappings
=> (IReadOnlyDictionary<string, TypeHandler>)_globalCompositeMappings; As workaround I've changed these lines to the following: internal static IReadOnlyDictionary<string, TypeHandler> GlobalCompositeMappings
=> _globalCompositeMappings.ToDictionary(a => a.Key, a => a.Value); If I compile Entityframework7.Npgsql from source against the Npgsql code changed according to the above it works on Mono, too. However I wouldn't submit a pull request for this since I'm not familiar with the internals of Npgsql and ToDictionary may introduce performance penalties. Moreover GlobalEnumMappings may be also affected this way. |
From @saxx on December 6, 2015 18:42 Seems to be the same problem as discussed in npgsql/npgsql#875 (mono 4.2 using reference source < 4.6, where there the cast to @roji Would it be a dreadfully bad idea to change the code as shown above by @kpocza? Or maybe change the cast from |
@saxx and @kpocza, calling ToDictionary on every call to GlobalCompositeMappings does seem like a bad idea performance-wise. However, there's no reason no to simply switch to IDictionary, instead of using IReadOnlyDictionary. I used the latter mostly as a defensive precautionary measure. I've just pushed a commit to use IDictionary instead, and will probably release alpha6 tomorrow (have some other pending things). |
Npgsql 3.1.0-alpha6 pushed to nuget, please test and confirm the problem goes away |
From @Praecursor210 on December 8, 2015 3:14 @roji I have this error on Linux (mono) and Windows (coreclr) with Npgsql 3.1.0-alpha6:
|
From @saxx on December 8, 2015 11:25 @Praecursor210 Please see the end of npgsql/npgsql#875 - should be the same error, @roji is already working on an updated EntityFramework7 NuGet package :) |
Have just published EntityFramework7.Npgsql 3.1.0-rc1-3 which should work well with Npgsql 3.1.0-alpha6, removing the usage of IReadOnlyDictionary. Please test and let me know how it goes. |
From @Praecursor210 on December 9, 2015 17:41 It's works fine on Windows (coreclr) and on Linux with Mono. I have one last problem, this exception when I try to add a Migration on Linux with coreclr:
|
From @cgarciae on December 11, 2015 22:59 Same problem
On Docker running on |
From @snissim on December 14, 2015 18:9 Yeah, I'm still having the same issue on alpha6 running coreclr on Linux (not mono). I found this linux port of System.Net.NetworkInformation. Might that help? https://www.nuget.org/packages/runtime.linux.System.Net.NetworkInformation/ |
Promise to take a look at this as soon as I can... |
Have produced a more precise repro and have opened aspnet/dnx#3262. This is definitely weird and seems like a DNX/CoreCLR issue on Linux, let's wait and see. |
From @snissim on January 4, 2016 4:14 So obviously running Npgsql on Linux is still uncharted territory, but I was able to get past the Now that I'm over that hurdle, I'm getting a timeout exception on any query. This works fine in Windows, and I'm able to psql via the postgres docker container without any issues. I tried upping the Timeout to 30 seconds in the connection string to no avail. The strange thing is, it errors out in well under 30 seconds (or even the default 15 seconds). Full stack trace:
|
From @thmulvany on January 5, 2016 7:54 Yep @snissim, this is exactly where I am. I added everything anyone recommended in : aspnet/dnx#3262 including: "System.Net.Security": "4.0.0-beta-23516",
"System.Net.NetworkInformation": "4.1.0-beta-23516",
"runtime.linux.System.Net.NetworkInformation": "4.1.0-beta-23516",
"runtime.unix.System.Net.Security": "4.0.0-beta-23516",
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516"
I am running rc1 update 1 on ubuntu linux. My code is a super simple web api that just queries a postgres instance (that works fine on windows) but when that same code is deployed (in a docker container) onto ubuntu and tries to connect to the same DB (which I verified is accessible from inside the running container by apt-getting postgres-client and using psql to run the same query) I get this error logged out directly after it logs "Opening connection 'Host=..." : fail: Microsoft.Data.Entity.Query.Internal.NpgsqlQueryCompilationContextFactory[1]
An exception occurred in the database while iterating the results of a query.
System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurre
d. ---> System.AggregateException: One or more errors occurred. ---> System.TimeoutException: The operation has timed ou
t.
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout) My project lock contains these NPGSQL entries: "EntityFramework7.Npgsql/3.1.0-rc1-3": {
"type": "package",
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.Relational": "7.0.0-rc1-final",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc1-final",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
"Npgsql": "3.1.0-alpha6"
},
"compile": {
"lib/dnxcore50/EntityFramework7.Npgsql.dll": {}
},
"runtime": {
"lib/dnxcore50/EntityFramework7.Npgsql.dll": {}
}
},
...
"Npgsql/3.1.0-alpha6": {
"type": "package",
"dependencies": {
"System.Collections.Concurrent": "4.0.11-beta-23516",
"System.ComponentModel": "4.0.1-beta-23516",
"System.ComponentModel.TypeConverter": "4.0.1-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Data.Common": "4.0.1-beta-23516",
"System.Diagnostics.Contracts": "4.0.1-beta-23516",
"System.Diagnostics.Tools": "4.0.1-beta-23516",
"System.Globalization": "4.0.11-beta-23516",
"System.Globalization.Extensions": "4.0.1-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Net.NameResolution": "4.0.0-beta-23516",
"System.Net.NetworkInformation": "4.1.0-beta-23516",
"System.Net.Primitives": "4.0.11-beta-23516",
"System.Net.Security": "4.0.0-beta-23516",
"System.Net.Sockets": "4.1.0-beta-23516",
"System.Reflection": "4.1.0-beta-23516",
"System.Reflection.TypeExtensions": "4.0.1-beta-23409",
"System.Runtime": "4.0.21-beta-23516",
"System.Runtime.Extensions": "4.0.11-beta-23516",
"System.Runtime.InteropServices": "4.0.21-beta-23516",
"System.Runtime.Numerics": "4.0.1-beta-23516",
"System.Security.Cryptography.Algorithms": "4.0.0-beta-23516",
"System.Security.Cryptography.Primitives": "4.0.0-beta-23516",
"System.Security.Cryptography.X509Certificates": "4.0.0-beta-23516",
"System.Security.Principal": "4.0.1-beta-23516",
"System.Text.Encoding.Extensions": "4.0.11-beta-23516",
"System.Text.RegularExpressions": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516",
"System.Threading.Thread": "4.0.0-beta-23516",
"System.Threading.Timer": "4.0.1-beta-23516"
},
"compile": {
"lib/dnxcore50/Npgsql.dll": {}
},
"runtime": {
"lib/dnxcore50/Npgsql.dll": {}
}
},
|
From @Banashek on January 24, 2016 19:24 Also currently getting a similar error. Have 2 docker containers on a coreos host, one aspnet5 app and one postgres server. Aspnet5 app is using rc1-update1-coreclr with the latest npgsql When attempting to run the migration from one container to the other, I receive the following stack:
|
From @blacky-i on January 24, 2016 19:39 Do not know how but migrations are working fine for me. But I'm running local. Without Docker. mono v 4.3.3 NIghtly project was created via yeoman |
From @Banashek on January 24, 2016 21:58 What operating system are you on? I attempted to use mono on my coreos/docker setup but instead get different errors:
This looks like a different error however. Is switching the runtime the only way to fix the type initialization error at the moment? |
From @blacky-i on January 25, 2016 10:55 @Banashek it seems like you forgot to add dependency
to your project.json file. OS - kubuntu 15.10
|
From @Banashek on January 25, 2016 18:59 Derp yeah that worked. So yeah now on coreos between docker containers that are properly networked, the migrations are working successfully. On coreclr still experiencing the TypeHandlerRegistry exception. So it seems to be an issue with the coreclr version of the dnx only then? |
From @efdee on February 11, 2016 21:47 Any progress on a fix for coreclr? |
Sorry, am going to be extremely busy in the next two months and it'll be unlikely I can get around to fixing this. I'll definitely be back focusing on Npgsql after that though. |
From @matthewvalimaki on April 1, 2016 12:59 For those on Linux container using coreclr getting connection timeout see https://github.com/dotnet/corefx/issues/4631#issuecomment-165521190. After adding extra dependencies mentioned here and applying binary from the comment above things started working for me. |
From @NinoFloris on April 21, 2016 0:53 I also have this with dapper, I'm at bleeding edge dotnet cli and netstandard monikers
|
Closing old issues - this should be fine on newer .NET Core. Please open a new issue if you're still seeing problems. |
From @Praecursor210 on November 19, 2015 20:22
I'm currently trying EntityFramework7 rc1-1. I have no problem on Windows but I have this exception on Linux with coreclr when I try to add a migration.
Copied from original issue: npgsql/npgsql#876
The text was updated successfully, but these errors were encountered: