System.Data.OracleClient.OracleConnection throws type initializer exception

1.4k Views Asked by At

I would like to ask help for a problem that I am facing. I was running a long task within a website. Because it was taking some time to process the task, I decided to change the structure. Shortly, now I am calling an exe from the website and monitoring the process. All is fine on my development environment. But when I try to run the exe on my prod environment, I get the following exception message. I use System.Data.OracleClient to connect to Oracle database.

The type initializer for 'System.Data.OracleClient.OracleConnection' threw an exception.

This happens when I call the exe from the website. I created a winforms app to test the exe. And if I call the exe from my winforms app (in the same way that I call from the website) everything works fine.

I searched the exception online. There were 2 suggestions I found.

1-) Different version of Oracle Client : This is why I created the test winforms app. It ran all fine. So I don't think Oracle client is the issue unless I'm missing something.

2-) 32-bit/64-bit OS issue : I initially compiled the exe targeting 32 bit environment. And my prod environment is 64 bit. So I tried to compile targetting 64 bit but got the same exception. Plus, 32-bit exe runs without any problems with my winforms test application. Also my development environment is 64bit as well, but I don't get the exception there.

Any ideas will be appreciated...


EDIT : I couldn't find a solution to type initializer exception. Actually I didn't have time to dig into it. So what I did instead is to call a winforms exe and simulating it's button click to call the actual exe. I didn't like the solution but I had to move on. I am no more getting the OracleConnection exception.

0

There are 0 best solutions below