Search code examples
servicestackormlite-servicestackbadimageformatexception

ServiceStack OrmLite Sqlite exception


I have the following lines of code:

IDbConnection dbConn = dbFactory.OpenDbConnection();
IDbCommand dbCmd = dbConn.CreateCommand();

I am getting the following exception:

BadImageFormatException An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

I thought this might have to do with 32 bit and 64 bit applications, so I tried both versions of the dll. In addition, I also enabled 32 bit applications through IIS. Can someone tell me why I may be getting this error?


Solution

  • Right, this is a result of trying to use a 32bit unamanged dll (Sqlite) on a 64bit pc.

    See this answer for solutions.

    Otherwise use a platform-specific Sqlite .NET wrapper: