ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 在64位平台使用SQL Server Compact

在64位平台使用SQL Server Compact

原创 Linux操作系统 作者:六人行-SQLServer 时间:2009-11-26 20:12:04 0 删除 编辑
今天在 Windows 7 x64 使用 Visual Studio 2008 开发了一个很简单的 SQL Server Compact 3.1 桌面应用程序,发现跑不起来。抛出以下异常:
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->  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模式运行的。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22903848/viewspace-620683/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-11-20

  • 博文量
    29
  • 访问量
    30388