System.BadImageFormatException when running ServiceStack examples.

I am trying to run ServiceStack Sample Projects. When I start the web client, I get the following error:

{System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_open_v2(Byte[] utf8Filename, IntPtr& db, Int32 flags, IntPtr vfs) at Mono.Data.Sqlite.SQLite3.Open(String strFilename, SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool) at Mono.Data.Sqlite.SqliteConnection.Open() at ServiceStack.OrmLite.OrmLiteConnection.Open() at ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection() at ServiceStack.Examples.ServiceInterface.Support.ConfigureDatabase .Init(IDbConnectionFactory connectionFactory) in E:\ServiceStack.Examples\src\ServiceStack.Examples\ ServiceStack.Examples.ServiceInterface\Support\ConfigureDatabase.cs:line 23} 

I downloaded the last System.Data.SQLite.dll file and tried to use it, but still getting the same error. I am running 64-bit VS2010 in a 64-bit box of Windows 7.

+7
source share
2 answers

Install the target platform of your main x86 project to fix this. This can be done in Project ... → Properties → Build.

SqlLite is most likely 32-bit components, and to download it, the application must also be a 32-bit application (64-bit processes cannot load 32-bit components and vice versa).

+10
source

This is a problem when trying to load 32-bit sqlite.dll with 64-bit IIS / pc.

To make it work, you need to enable "Enable 32-bit applications" for your AppDomain:

  • Opening IIS Manager
  • Click "Advanced Settings" in your application pool.
  • Set Enable 32-bit applications to true

For a more timely response, feel free to send a link to any ServiceStack-related questions in the ServiceStack Google Group .

Update: I forgot to add: you also need the highest level project (i.e. your ASP.NET web application) so that its build configuration is set to x86 (32 bit).

If you download the latest version of ServiceStack.Examples (v2.01) , now it should work on 64-bit servers.

More information about this can be tracked by:

https://groups.google.com/d/topic/servicestack/EUPqF2jI4ig/discussion

+7
source

All Articles