System.BadImageFormatException on running ServiceStack examples.

左心房为你撑大大i 提交于 2019-11-28 00:29:04

问题


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.Examples\src\ServiceStack.Examples\
    ServiceStack.Examples.ServiceInterface\Support\ConfigureDatabase.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.


回答1:


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).




回答2:


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



来源:https://stackoverflow.com/questions/4657087/system-badimageformatexception-on-running-servicestack-examples

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!