【问题标题】:System.BadImageFormatException on running ServiceStack examples.运行 ServiceStack 示例时出现 System.BadImageFormatException。
【发布时间】:2011-06-07 02:59:12
【问题描述】:

我正在尝试运行 ServiceStack 示例项目。当我运行 Web 客户端时,出现以下错误:

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

【问题讨论】:

    标签: sqlite badimageformatexception servicestack


    【解决方案1】:

    这是尝试使用 64 位 IIS/pc 加载 32 位 sqlite.dll 时出现的问题。

    要使其正常工作,您需要通过以下方式为您的 AppDomain“启用 32 位应用程序”:

    1. 打开 IIS 管理器
    2. 点击应用程序池中的“高级设置”。
    3. 启用 32 位应用程序设置为 true

    如需更及时的回复,请随时将任何 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

    【讨论】:

      【解决方案2】:

      将主项目的平台目标设置为 x86 以解决此问题。这可以在 Project... -> Properties -> Build 下完成。

      SqlLite 很可能是 32 位组件,要能够加载它,您的应用程序也需要是 32 位应用程序(64 位进程无法加载 32 位组件,反之亦然)。

      【讨论】:

      • 我尝试了 Any CPUx86 但仍然遇到同样的错误。
      猜你喜欢
      • 2013-02-09
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-28
      • 2014-02-26
      • 2017-09-15
      • 2016-07-31
      • 1970-01-01
      相关资源
      最近更新 更多