Program not working on 64 bit Windows - c#

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.

Related

Why would a x86 compiled application work on 64 bit windows machine?

I installed windows 7 64 bit and then I installed visual studio 2015 then created C# application using windows forms and I compiled this application as x86 (as shown in screenshot) to creat the exe file . After that I installed the .exe file on another 64 bit windows 7 and the application worked fine!
My question is: why this x86 complied application would work on 64 bit machine. I read that if I compile application as x86 it would only work on x86 machines.
Can anyone explain why it worked on 64 bit machine? thank you
The reason is because your 64bit CPU is specically designed for this as well as the operating system you're using.
In short, the OS detect that you're trying to run a x86 application and put the CPU in x86 compatibility mode before executing your application.

Deploying application using SQL Server CE 4.0 SP1 using "Any CPU"

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

Running in 64 bit mode with the 32 bit Oracle client installed

I have Developed an Applicatoin in ASP.NET with C# and I have used oracle database.
my prob is when I am running this application from visual studio 2012 it will throw error like
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.
but when I host this application in my local iis and make application pool enable 32bit is true then it's working fine.
can anyone please guid me how can I run this from visual studio.
If it is just the ODP use the managed driver from Oracle.
http://www.nuget.org/packages/odp.net.managed/

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine

I have installed the 'Microsoft Access Database Engine 2010 Redistributable' as described in the blog entry
http://danielcai.blogspot.com/2011/02/solution-run-jet-database-engine-on-64.html
and it works in my windows-forms application. I now want to add some unit-tests and when running the unit-test I get the above error. I have checked my references but can't seem to figure out why it works in the application and not in the unit-test.
I'm working in VS2010 on a windows 7 ultimate x64 installation.
Can someone please help me ?
The Target Platform is probably set to Any CPU, which means when you run it from VS or in your 64-bit Windows it will execute as 64-bit code (and use the 64-bit Jet driver). But a typical unit test runner is executing in 32-bit mode and all assemblies it loads will then execute in 32-bit mode (since your project target platform is Any, ie either 32 or 64 bit). And Windows 7 does not come with a 32-bit Jet driver by default.

oracle error in windows-7 64bit

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.

Categories