The type initializer for 'Sybase.Data.AseClient.AseConnection' threw an exception

5.8k views Asked by At

I created ASP.Net web application in Visual Studio 2013. This application uses Sybase.Data.AseClient.dll to connect to Sybase database.

When I press F5 and debug application then it runs fine. No issues. But when I publish it using VS in C:\inetpub\wwwroot folder then I get following error when trying to browse the website:

The type initializer for 'Sybase.Data.AseClient.AseConnection' threw an exception.

How do I fix this issue?

EDIT

Inner exception being thrown is shown below.

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at Sybase.Data.AseClient.Unmanaged.AseGetDriverVersion(StringBuilder value, Int32 capacity) at Sybase.Data.AseClient.AseConnection.CheckVersion()

2

There are 2 answers

0
user3247097 On
  1. On IIS, select aplications pools on left panel
  2. Select the aplication pool used on the website on the center panel
  3. Click on advanced Settings on the rigth panel
  4. On "Enable 32-Bit Applications" set the value to true
  5. stop and start the aplication pool
0
Aditya Bhouraskar On

It's a little late but if anyone is facing the same problem maybe this could help. I was facing the same exception error when I was trying to schedule a batch job to access a Sybase DB. However, the scheduler was a 64 bit program and the 'Sybase.Data.AseClient.dll' that I was using was a 32 bit one. What worked for me was to replace the dll with a 64 bit dll 'Sybase.AdoNet4.AseClient.dll' that I found in the path C:\Sybase\DataAccess64\ADONET\dll