2011-01-11 56 views
7

我試圖運行ServiceStack示例項目。當我運行的Web客戶端我收到以下錯誤:運行ServiceStack示例的System.BadImageFormatException。

{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} 

我已經下載了最新的System.Data.SQLite.dll文件,並試圖使用它,但我仍然得到同樣的錯誤。我在Windows 7 64位機器上運行64位VS2010。

回答

10

將主項目的平臺目標設置爲x86來解決此問題。這可以在Project ... - > Properties - > Build下完成。

SqlLite最有可能是32位組件,爲了能夠加載它,您的應用程序也需要是32位應用程序(64位進程無法加載32位組件,反之亦然)。

+0

我已經試過**任何CPU **,** ** 86,但仍然得到同樣的錯誤:

關於這方面更多的信息可以被追蹤。 – TheVillageIdiot 2011-01-12 06:40:29

7

當試圖加載64位IIS/PC的32位sqlite.dll時,這是一個問題。

得到它的工作,你需要「啓用32位應用程序」爲您的AppDomain是:在你的應用程序池

  1. 開放IIS管理器
  2. 點擊「高級設置」。
  3. 啓用32位應用程序

對於響應更及時隨意鏈接到任何ServiceStack相關的問題發送到ServiceStack Google Group

更新:我忘了補充:您還需要您的最高級別項目(即您的ASP.NET Web應用程序)將其生成配置設置爲x86(32位)。

如果你下載latest version of ServiceStack.Examples (v2.01)這現在應該在64位服務器上工作。

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