zoukankan      html  css  js  c++  java
  • 在64位平台使用SQL Server Compact(转)

    今天在 Windows 7 x64 使用 Visual Studio 2008 开发了一个很简单的 SQL Server Compact 3.1 桌面应用程序,发现跑不起来。抛出以下异常:  Message: "An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"

      StockTrace:

      StockTrace

      System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT:
    0x8007000B)

      at System.Data.SqlServerCe.NativeMethods.CreateErrorInstance(IntPtr
    & pError)

      at System.Data.SqlServerCe.SqlCeCommand..ctor()

      at WindowsApplication1.NorthwindDataSetTableAdapters.EmployeesTableAdapter.InitAdapter()
    in D:\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\NorthwindDataSet.Designer.cs:line 6400

      at WindowsApplication1.NorthwindDataSetTableAdapters.EmployeesTableAdapter.get_Adapter()
    in D:\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\NorthwindDataSet.Designer.cs:line 6324

      at WindowsApplication1.NorthwindDataSetTableAdapters.EmployeesTableAdapter.Fill(EmployeesDataTable dataTable)
    in D:\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\NorthwindDataSet.Designer.cs:line 6607

      at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e)
    in D:\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs:line 29

      at System.Windows.Forms.Form.OnLoad(EventArgs e)

      at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

      at System.Windows.Forms.Control.CreateControl()

      at System.Windows.Forms.Control.WmShowWindow(Message
    & m)

      at System.Windows.Forms.Control.WndProc(Message
    & m)

      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message
    & m)

      at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

      仔细想了想,SQL Server Compact 3.5 SP1 才开始本机支持64位平台,那么 SQL Server Compact 3.1和3.5应该只能通过WOW64模式运行。WOW64 是一个允许32位应用程序运行在64位平台的仿真层,让它们好像是在32位平台上运行。

      经过在网络上查找,也有其他人遇到过类似的问题,一般的回答都是安装64位版本的 SQL Server Compact 3.5 SP1,可是我现在要解决的是 SQL Server Compact 3.1。后来在这里找到了解决的方法!Visual Studio 2005/2008 创建的项目默认的目标平台是“Any CPU”,将它改为x86就可以了,这样编译后的程序是通过WOW64模式运行的。

  • 相关阅读:
    转 JQuery 爱好者们的福音:jQuery EasyUI 开源插件套装 完全替代ExtJS 武胜
    转 自己做的C#版ILMerge,可将所有引用的DLL和exe文件打成一个exe文件,有图解 武胜
    关于文件结束符EOF feof 区别
    OpenLDAP中文版帮助文件(转)
    文件结束符EOF .
    VMware中Linux系统网络配置
    Python 字符串格式化输出(format/printf)
    李彦宏创业12年解读:企业家精神改变工程师命运
    gcc命令行详解
    如何成为一名 Google 软件工程师?
  • 原文地址:https://www.cnblogs.com/MayGarden/p/1768147.html
Copyright © 2011-2022 走看看