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.

Type Initializer Error Thrown by linq2db InformixDataProvider when run in Web API Application

See original GitHub issue

I’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.

code.zip lib.zip

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:closed
  • Created 6 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
ExzaSolutionscommented, Mar 5, 2019

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.

1reaction
sdanylivcommented, Oct 5, 2017

Reproduced, thanks for sample project. Trying to figure out how to fix correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type Initializer Error Thrown by linq2db ...
So running in the context of a web application throws an error, but running in a console application is fine. below is line...
Read more >
Type Initializer Error Thrown by linq2db InformixDataProvider ...
Coding example for the question Type Initializer Error Thrown by linq2db InformixDataProvider when run in Web Application but not Console-C#.
Read more >
How to Handle the Exception-In-Initializer-Error in Java
Java's ExceptionInInitializerError occurs when an unchecked exception takes place in a static initializer or static variable assignment.
Read more >
How to resolve "The type initializer for 'Gdip' threw an ...
I deployed the code in Kubernates and found the below exceptions in logs and not working. What was the solution to resolve this...
Read more >
When Does Java Throw the ExceptionInInitializerError?
The ExceptionInInitializerError indicates that an unexpected exception has occurred in a static initializer. Basically, when we see this ...
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