Type Initializer Error Thrown by linq2db InformixDataProvider when run in Web API Application
See original GitHub issueI’m testing linq2db for an Informix connection, it is working fine in a Windows Forms application, but when I tried to use the same code to connect from an ASP.NET Web API application it throws an exception when creating InformixTools.CreateDataConnection(…)
Apparently, it’s the same issue described here: https://stackoverflow.com/questions/30171835/type-initializer-error-thrown-by-linq2db-informixdataprovider-when-run-in-web-ap
I downloaded source code and I modified the line 128 in InformixDataProvider.cs (as described by quintopereira) and it’s working now.
Anyway, I’m attaching the project to reproduce the problem. I don’t want to make own fixes in linq2db to avoid problems when updating.
Exception message:
The type initializer for 'IBM.Data.Informix.IfxDecimal' threw an exception
Stack trace:
en lambda_method(Closure )
en LinqToDB.DataProvider.Informix.InformixDataProvider.GetNullValue(Type type) en C:\Desarrollo\coilvalidation\code\Linq2DB\Source\DataProvider\Informix\InformixDataProvider.cs:línea 128
en LinqToDB.DataProvider.Informix.InformixDataProvider.OnConnectionTypeCreated(Type connectionType) en C:\Desarrollo\coilvalidation\code\Linq2DB\Source\DataProvider\Informix\InformixDataProvider.cs:línea 118
en LinqToDB.DataProvider.DynamicDataProviderBase.GetConnectionType() en C:\Desarrollo\coilvalidation\code\Linq2DB\Source\DataProvider\DynamicDataProviderBase.cs:línea 41
en LinqToDB.DataProvider.DynamicDataProviderBase.IsCompatibleConnection(IDbConnection connection) en C:\Desarrollo\coilvalidation\code\Linq2DB\Source\DataProvider\DynamicDataProviderBase.cs:línea 51
en LinqToDB.Data.DataConnection..ctor(IDataProvider dataProvider, IDbConnection connection) en C:\Desarrollo\coilvalidation\code\Linq2DB\Source\Data\DataConnection.cs:línea 188
en LinqToDB.DataProvider.Informix.InformixTools.CreateDataConnection(IDbConnection connection) en C:\Desarrollo\coilvalidation\code\Linq2DB\Source\DataProvider\Informix\InformixTools.cs:línea 43
Environment details
linq2db version: 1.9.1
Database Server: Informix 11.50.0000 FC8GE
Database Provider: IBM.Data.Informix
Operating system: Windows 10
Framework version: .NET Framework 4.6.2
Thanks in advance and best regards.
Julio S.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (8 by maintainers)
Hi I fixed my issue,had the same error. So there is a tool called setnet that installs with informix sdk. If you open that tool there is a field CLIENT_LOCALE. I set that to EN_US.UTF8 and now it is working.
Reproduced, thanks for sample project. Trying to figure out how to fix correctly.