Several users running various x64 version of Windows are facing problems when trying to develop or deploy solutions based on SQL Compact. The problems comes from the fact the SQL Compact is only supported in 32 bit WoW (Windows on Windows) mode on the x64 platform. This gives problems in two situations: When trying to run .NET Framework based applications, and when trying to use the SQL Compact Synchronization Agent (sqlcesa3x.dll) on x64 version of Internet Information Services (IIS).
Making .NET applications that depend on SQL Compact work on a x64 system
Any new project you start in Visual Studio is by default targeted to the "Any CPU" platform:
This means that unless modified either by changing the build configuration (if you have built the application yourself) or modifying the .exe file by using corflags.exe (if you have not built the application yourself), the application will execute under the default .NET Framework, which is a x64 version on the Framework on the x64 platform. Since your application depends o several unmanaged DLL files, namely the SQL Compact DLLs, it will not be able to use SQL Compact and fail.
Here is how to change the target platform from within Visual Studio:
(If you do not see this drop down, go to Tools, Options, Projets and Solutions, and make sure "Show advanced build configurations" is checked)
.
Select the Configuration Manager from the drop down above:
Select <New...> and selcet x86 from the top drop down:
(and click OK and Close)
Now you configuration look like this:
You are good to go, since your application will now be forced to use the 32 bit version of the .NET Framework always, even on a x64 platform.
Forcing 32 bit (if you do not have the source code)
In order to do this, use the .NET Framework SDK tool called corflags.exe.
Launch a Visual Studio command prompt, and you can use corflags.exe:
The flag you need to set is the 32BIT flag, so use a command line like this against your .exe file:
corflags C:\myprogram.exe /32BIT+
Your application will now be forced to use the 32 bit version of the .NET Framework always, even on a x64 platform.
Runnning the Replication Agent on a x64 version of IIS
The x64 version of IIS runs by default in x64 mode. This caused many problems for 32 bit ISAPI DLLs, for example sqlcesa30.dll and sqlcesa35.dll - the SQL Compact replication agent DLL. You need to configure an application pool to run in 32 bit mode. In IIS 7 this is quite simple, as demonstrated here.
In IIS 6, enabling this is slightly more complicated, and forces all application pools on your IIS server to run in 32 bit mode. Windows Server 2003 Service Pack 1 is required for this to work. How to enable this is documented here.
32 comments:
Thank you!
This completely solved my problem. I had an application that was working great on my development machine (XP Professional SP3) but when placed on the Server (Windows Server 2003 x64) I got that crazy error.
Thank you very much!
I am using a Toshiba A200 with an Intel Core Duo. I cannot get past this error (and just doing my 1st walkthrough http://msdn.microsoft.com/en-us/library/bb546200.aspx)
Even though I'm not using a 64 bit machine, I followed your instructions, but no dice.
Completely stumped. Can't find any MS doc on this.
Hi John,
I suggest you post the exact error message and other relevant information on the SQL Compact forum: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=152&SiteID=1
Okay, have done that.
I also encountered the same error. My OS is: Vista Ultimate x64 Edition. .NET 3.5 - Visual Studio 2008.
A very thanks for your tip. If there is any final solution, please update the post.
- Srinath Sadda,
Microsoft MVP 2008 - Windows/Shell
As I said, I tried all that and it didn't solve the problem. I had installed from the VS 2008 Education DVD and I decided to download and reinstall SQL Compact from the MS site on its own. As I have had no further problems after doing this, I think my problem was install related. However, I will bear in mind the CPU setting.
this option page seems to be for c++/cli
so how do i do it for c#?
The screenshots are from a C# installation. Also, now x64 support for the runtime is available with SQL Compact 3.5 SP1. Download from here: http://www.microsoft.com/downloads/details.aspx?FamilyID=dc614aee-7e1c-4881-9c32-3a6ce53384d9&displaylang=en
Thank you very very very much!
Man, where are the pics?? I'm in need of this.
Mamendes: I don't see any missimg pictures !?
thanks, this worked for our applications running against sql compact 3.5sp1 dlls, and another c# app running against xtreme toolkit activex
Thanks, Microsoft should be ashamed. This problem has been around for a while.
Thanks for the tip on this issue.
Best regards!
Installing service pack1 for SQL Server Compact 3.5 fixes the problem
http://www.microsoft.com/downloads/details.aspx?FamilyId=DC614AEE-7E1C-4881-9C32-3A6CE53384D9&displaylang=en#filelist
steps which mentioned in the blog of x64 and SQL Compact are valid when we develop application on windows only not for smartdevice->windows CE
because when i create project under visual studio -> smartdevices - > windows CE , in configuration manager m not able to change Plateform to x86
and also create new plateform is disabled.
so pls tell me how to create new plateform for smartdevice application
steps which mentioned in the blog of x64 and SQL Compact are valid when we develop application on windows only not for smartdevice->windows CE
because when i create project under visual studio -> smartdevices - > windows CE , in configuration manager m not able to change Plateform to x86
and also create new plateform is disabled.
so pls tell me how to create new plateform for smartdevice application
Ritesh/JAINA: x64 is not an issue on Windows CE
Thanks! Exactly what I needed!
Hi all, I got win xp sp3, IIS and sql server compact 3.5 sp1.
https://192.168.0.95/sync2/sqlcesa35.dll?diag its working with basic authentication.
When synchronize via http://192.168.0.95/sync/sqlcesa30.dll (non SSL) works fine, but, if change to https link above, got same error. Any one can help me plz? :(
Thanks for the great walk through
Thank you so much! I have been banging my head against the wall trying to figure this out for 2-3 hours! I am so relieved!
Thank you, thank you, thank you. It worked.
VB Express 2008, running on Vista. First the debug wouldn't work. Then the setup.exe file quit working when I followed the directions to upgrade to SP1 and re-install VBE 2008. Then I had to run VB as administrator. Then I got the missing dll error. Total portion of life spent on this crap that I'll never get back: 10 hours.
Total time it took your fix to work: 10 minutes.
Windows' new slogan:
Redefining "User Hostile"
THANK YOU soooooooooooooooooooo Much!!
It really worked...it Solved my problem :)
Hello, switch to x32 is a workaround and lacks the ability to compile for x64. I'v just found the decision to the problem.
I'v checked the decision on Windows 7 x64.
First, uninstall all SQL Server Compact products which install with Visual Studio 2008 SP1.
Second, download SQL Server Compact SP1 x32 and Server Compact SP1 x64. I'v downloaded them from MSDN Subscribtion.
Then install SQL Server Compact SP1 x32.
Finally install SQL Server Compact SP1 x64.
Thats' all! Now it works for me if Any CPU is choosen.
Erik
I have VB Express and could not get the data demos in the training instructions to work. This fix solved the problem on the 64 bit machine.
Thanks this really helped my out after a lot of struggling with local db deployment on x64 platforms!!!
Well explained Erik, solved my headache in no time. But is there any way to set this flag permanently, or am I going to have to manually set the x86 flag with each project?
I'm running Windows 7 SP1 and using SQL Compact 3.5 on an i5 processor. I can't use the link you posted for 3.5 because the System details do not include W7.
3.5 SP2 is now available for x64 as weel, so you do not need to use x86 platform any more - see http://erikej.blogspot.com/2010/11/sql-server-compact-private-deployment.html
I tried changing my project's platform from "Any CPU" to "x86" but was only partially successful - I could select "" in the "Active solution" combobox at the top of the Configuration Manager, but in the "Project.Configuration.Platform.Build" grid, the Platform dropdown only had an "Edit..." option, and wouldn't really allow me to Edit the existing "Any CPU"
So I end up with a Configuration Manager dialog that shows "Debug x86" above but "Debug Any CPU" in the grid...???
If the corflags trick is used and you DO have the source code, it would have to be re-run after every build of the .exe, correct?
Clay: Edit should allow you to define an x86 build platform based on the current one. And corflags must be run after each build, yes. And this blog post is very old, I have other with clearer x64 solutions
Post a Comment