English 中文(简体)
System.BadImageFormatException on running ServiceStack examples.
原标题:

I am trying to run ServiceStack Examples projects. When I run the web client I am getting 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.ExamplessrcServiceStack.Examples
    ServiceStack.Examples.ServiceInterfaceSupportConfigureDatabase.cs:line 23}

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

最佳回答

Set the platform target of your main project to x86 to fix this. This can be done under Project... -> Properties -> Build.

SqlLite is most likely a 32-bit components, and to be able to load it your application needs to be a 32-bit application as well (64-bit processes cannot load 32-bit components and vice versa).

问题回答

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

To get it to work you need to Enable 32-bit Applications for your AppDomain by:

  1. Opening up IIS Manager
  2. Click Advanced Settings on your Application Pool.
  3. Set Enable 32-bit Applications to true

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

Update: I forgot to add: you also need your top-most level project (i.e. your ASP.NET web application) to have its build configuration set to x86 (32bit).

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

More information about this can be tracked on:

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





相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签