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

  • 相关阅读:
    关于git---远程
    关于git---主要
    css特效
    Canvas图片压缩
    TypeScript简单介绍
    html 常见兼容性问题及解决方法
    cookies,sessionStorage 和 localStorage 的区别
    vue-element-admin vue.config.js
    ② nodejs + mongodb 搭建服务器
    ① 数据自动填充
  • 原文地址:https://www.cnblogs.com/MayGarden/p/1768147.html
Copyright © 2011-2022 走看看