I am planning to create an application which uses SQL Server CE 4.0 SP1 using private deployment.So now i am planning to use private deployment. So all the dll must be included in the project as explained here.
But I tried just adding all dll from my XP PC (32 bit) and not added any 64 bit dlls (but it was mentioned to add 64 bit dlls). Then i set platform to "Any CPU". After building application i tried running my application in a 64 bit PC and it worked properly!!! I was expecting it would give error as i have not included 64 bit dlls.
Then I used isWow64Process api to check whether the application is really running on 64 bit. It returned false when i set "any cpu" and 64 bit, means it runs on 64 bit.When i set to x86 it returns true which means it is running under wow64(as 32 bit process). If I set it to x64 it works properly in 64 bit pc, but SQL Server CE dlls are of 32 bit. why does this happen? My plan is to use "Any cpu" so that it works as 32 bit in 32 bit PC and 64 bit process in 64 bit pc. So what i am missing. Why does it work even if i set any cpu or x64?
EDIT:
I have found the reason why it was working on 64 bit PC.its because the pc already had SQL CE 4.0 SP1 installed. So application used dll from installed path instead of using files from app path where it had 32 bit dll which dont support 64 bit application(any cpu).
But now I am following the link mentioned above and added x86 and AMD64(not x64 as mentioned in that link) folder and corresponding dlls and Microsoft.VC90.CRT dlls properly, it works properly on windows 7(.net 3.5 by default- sql ce is not installed). In windows XP sp3 (fresh install with only OS) I installed .net 2.0 and then run my application. It worked!!
1) So does SQL CE 4.0 SP1 private deployment require .net 3.5? Will it cause any other problem if i use only .net 2.0?
2)I found like we need to modify app.config to refer to the Private ADO.NET provider, which has assembly version 4.0.0.1, not 4.0.0.0 as the on in the GAC which is mentioned here I have not done this and it and my application worked properly. So is it required to do? If i don't add it will it cause error in any .net framework?
3) I have not included System.Data.SqlServerCe.Entity dll. I am using SqlCeConnection to connect to database. So is there any need of adding System.Data.SqlServerCe.Entity dll? Also some where i found like this dll require .net 3.5 so microsoft recommends installing .net 3.5 for private deployment of SQL CE 4.0 SP1(related to my 1st question)?
You can download my project here
Related
I have programmed (with Visual Studio, C#) an application that connects to an Oracle database and does stuff. It works fine on my pc with sample database, my Windows is 32 bit, but as soon as I upload it to the server which has a 64 bit Windows, I get an error:
The provider is not compatible with the version of Oracle client
I have set target platform on "any cpu" in Visual Studio.
What should I do to have it run on both 32 bit and 64 bit Windows?
C# Database providers are usually 32bit or 64bit (you didn't state the database provider you used).
If you set your program to be any CPU , at run time it will be compiled to either 32bit or 64bit which is determined by locally installed .Net framework.
Since your developing machine is 32bit , it runs as 32bit and has locally installed database provider of 32bit.
When you try to run it on your server , it runs as 64bit and doesn't find a provider for 64bit.
You seems to either need to install a 64bit provider on your server or compile your program to x86.
I am planning to create an application which uses SQL CE 4.0. I saw like there are two types of deployment central and private. So now i am planning to use private deployment. So all the dll must be included in the project as explained here.
But I tried just adding all dll from my XP PC(32 bit) and not added any 64 bit dlls(but it was mentioned to add 64 bit dlls). Then i set platform to x86. After building application i tried running my application in a 64 bit PC and it worked properly. I was expecting it would give error as i have not included 64 bit dlls.
So the reason for proper working in 64 bit pc is due to x86 platform which I have set? Also can I use same method to deploy application and give it to my customers(instead of using 32 bit and 64 bit dll separately)?
EDIT:
In a windows XP PC i installed only .net 2.0 and then run my application which has sql ce 4.0 SP1 private deployment and it worked fine.
Then i tested central deployment(no dlls in application path) in same pc after installing sql ce 4.0 sp1 , while running application I got error like
System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
Then i uninstalled sql ce 4.0 sp1 and then installed sql ce 4.0 (without sp1) and now central deployment application worked!! So what is the problem actually?
In SQL CE 4.0 download page it's mentioned like .net 3.5 SP1 is the minimum requirement. So does private deployment works only with .net 2.0?Also why i got error for central deployment with sql ce 4.0 sp1?
Yes, forcing x86 is a good and simple approach, and will eork well on both desktop platforms
As title suggests I am compiling C# app using VS 2012 on a 64-bit machine. I would like the program being built to run on a 32-bit machine.
Right now the only help I found online was for:
Menu>Build>Configuration>
Active Solution Platform defaulted to Any CPU, and I tried that but didn't work on 32-bit machine (unless I did something wrong)
Tried Add a new one to the Debug configuration for platform x86 with build checked
Compiled and ran the app on 32-bit machine getting error A.exe is not a valid Win32 application.
My above was similar to what was done here: Link to Stack Overflow Similar Question
UPDATE 1:
The target OS is WinXP SP3 but we dont believe it has .NET 4.5 on it. I will be testing to see if compiling earlier ver of the app in .NET 4.0 will solve the problem and fix the problem. The problem may not be what the error message is displaying.
Setting your project to target AnyCPU should allow it to run on a 32bit machine, provided you aren't using a library which loads 64bit native code. If you have any dependencies, you'll need to make sure to use AnyCPU or 32-bit versions of those dependencies, as well. Also, make sure you have the proper .NET Framework installed on the 32bit machine (.NET 4.5 by default, if you're using VS 2012 with a new project).
Note that the default in VS 2012 for new projects is AnyCPU, with the Prefer 32 Bit option checked. This will cause it to always run as a 32bit application, even on your 64bit OS.
Note that, since your friend is running XP sp3, you can't use .NET 4.5. .NET 4.5 is not supported on Windows XP. You will need to change your application to target .NET 4.0, which will then work on the XP machine (if he installs the 4.0 framework).
That error is the Win32 error ERROR_BAD_EXE_FORMAT. It's generated by the loader and is what happens when you try to run a 64 bit process on a 32 bit operating system. There are other ways to see that error, but this is by far the most common reason for it to occur on a .exe file.
To compile a 32 bit process you need to target x86 in your project configuration. Another alternative would be to target AnyCPU. That will result in a 32 bit process when executed on a 32 bit OS, and a 64 bit process when executed on a 64 bit OS. It would appear that your build targets x64.
The Platform name (shown on the top of the properties, page "Build") is only a name. The same for "Active Solution Platform" in configuration editor. This is a bit confusing.
You have to make sure that the "Target platform" setting is really set to "AnyCPU" or "x86".
I had same problem. I strugle with it. and the and I found a solution.
The solution is :
Firstly choose platform target "x86". After that build your project as "release mode" not "Debug mode". finally you can run on any platform (32 bit or 64 bit).
If none of the solutions presented above helped you, then try the following:
Open the project properties and click General in the left column.
Change Platform Toolset to the one with Windows XP in it.
For example, in Visual Studio 2015 it will default be set to "Visual Studio 2015 (v140)". To be able to run on Windows XP, you have to change this to "Visual Studio 2015 - Windows XP (v140_xp)".
Now do a full rebuild, and the exe should work on Windows XP.
I installed windows-7 64 bit. When I try to run my program (that works with Oracle 11g) I get this error:
Attempt to load Oracle client libraries threw BadImageFormatException
this problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed
What can be the problem ? Where I can download 64 bit oracle client ?
(can I get any link for download)
thanks in advance
Have you tried download the 64bit Oracle Client from:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.htmlBlockquote
This looks like it might be the correct download:
Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64)
win64_11gR2_client.zip (615,698,264 bytes) (cksum - 2947608743)
Contains the Oracle Client Libraries. Download if you want the client libraries only
Alternatively, if you cannot obtain a 64 bit version of the Oracle client and are stuck with the 32 bit version, then you can either:
rebuild your .NET application to
only run as a 32 bit (x86) process
instead of "Any CPU" or
use CorFlags.exe (CorFlags
Conversion Tool) to reconfigure
your existing .NET application exe
to run as 32 bit without having to
rebuild it.
I'm trying to get a firebird web application (IIS6 64 bit) to run. However I'm getting bad image format (bit difference incompatability) issues. Has anyone got any advice to get it running.
Details AnyCPU application references the .net firebird driver (through nhibernate) which uses a native 64bit dll. There is a native 32bit dll which I use for local development and it works fine. (I havn't got the 32 version working on the 64 bit server either).
This issue actually formed from how we deployed our website. The site is packaged on a 32bit computer what I didn't realize is that it also packed the 32bit native fire-bird dll's instead of the 64bit ones.