Microsoft Study Bible

November 25, 2009

SQL Server Compact on Windows 7 x 64-bit

Today, when I use Visual Studio 2008 to develop a simple SQL Server Compact 3.1 application on Windows x64 platform, throws the following exception:

Message: “An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0×8007000B)”

StockTrace:

  StockTrace

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

  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)

Think it carefully .SQL Server Compact 3.5 SP1 just can support Win7 x 64 platform, SQL Server Compact 3.1 and 3.5 should run only through WOW64 mode .WOW64 is an Emulation Layer which allow 32-bit applications run on 64-bit platform. This seems that the 32-bit applications run on the 32-bit platform.

That problem is familiar on the internet .Generally speaking ,the answer is to install 64-edition SQL Server Compact 3.5 SP1.However ,what I need to resolve is SQL Server Compact 3.1 .What should we do ?

It is very simple. “Any CPU” is the default target platform Visual Studio 2005/2008 creates the project on. we just change it to be “x86”.So,the complied program will run through WOW64 mode.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

Close
E-mail It