OracleClient works with WPF application but not web application - visual-studio

I am porting a WPF application to a web application (ASP.net & C#). My IDE is Visual Studio 2008 and we are using Oracle 11g. My OS is Windows 7 , 64-bit. THe WPF application uses System.Data.OracleClient to connect to our database and it works fine. I added the OracleClient reference to the workspace and tried using the same namespace in the ASP.Net application but I get an error when trying to connect to the database (.Open()). The error is:
"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."
I checked the configuration manager in the WPF application and the web app. They are set the same:
Platform - AnyCPU
I tried using the 64-bit version of Oracle Client and it still gives me the same error.
I did this by removing the reference to System.Data.OracleClient located in Windows/Microsoft.NET\Framework\v2.0.50727 and added the reference to the 64-bit version in Windows/Microsoft.NET\Framework64\v2.0.50727.
Any suggestions or help would be appreciated.
Thanks

Related

How to connect .net API to MS Access database

Dear Experts : I have an existing MS Access database , and I have created a web API using Visual Studio 2019. I am trying to create an ADO.net entity data model or even Code first . The problem is that I cannot find in the data source when I create new data source , the oledb .
Any idea how to connect to Access via API
Thanks in-advance
Do you have the Access database engine installed?
I would install the Access database engine from here:
https://www.microsoft.com/en-us/download/details.aspx?id=54920
Make sure you choose the correct bit size. If you running the web server as x32 bits (the default), then install Access x32 (x86) version. If you are running your .net application as x64 bits, then install the x64 bit version of Access. Keep in mind that Visual Studio is a x32 bit application. So, if you choose "any" CPU, it will launch your application as x32 bits.
If you force your project to x64, then you need to have installed the x64 bit version of the Access database engine. Keep in mind that running as x64 bits will work for debug, and running and testing. However, while you can use the connection builders in VS, the final test connection will ALWAYS fail if you using the x64 bit version of Access. This is because VS is a x32 bit application. So, the test connection button will not work, and if you going to use the dataset designer (or now the newer version (entity frame work), then you best develop with the x32 bit version of Access.
If you just developing local, then not a problem, but most hosted web sites (in fact near all) are x64 bits). If you not using the IIS express local, then you have to force your project to x64 bits. And testing connections to the database will be a challenge (your code, or debug code will work, but actual test connections from VS will fail if your project is forced as x64 bits.

Oracle 11g - client and network component were not found Windows Server 2008 x64

I'm having this error frequently. I'm running a ASP 2.0 app on a Windows Server 2008 with Oracle 11.2 x64. I have installed Oracle 11 Client x32 but my Application Pool has the "Allow 32 bits Aplications" config enabled. Also I've reviewed my path and Oracle_home but everything seems normal. My connection provider is MSDAORA. The application eventually shows this error , not always. So I want to know if there are some configs or events logs or configs that I could review to find what the problem is.
Also I tried with the OraOLEDB.Oracle but I have this unknown error for some queries
OraOLEDB.Oracle
All the necesary dll's are registered.
System Info:
Windows Server 2008 x64
Oracle 11g R2
Oracle 11g Client x32
ASP v2.0
Provider MSDAORA
Application pool allows 32 bit apps
Path:C:\Oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN;C:\ProgramData\Oracle\Java\javapath;C:\Oracle\product\11.2.0\dbhome_1\bin;C:\Oracle\product\11.2.0\client_1\bin;...
System has registered ORACLE_HOME key for ASP 2.0 as C:\Oracle\product\11.2.0\client_1\
The system is on production, web pages are compiled.
I solved it by checking and configuring a DNS entry on ODBC Manager. The DNS must point to my oracle client folder.

Deploying MVC/Entity Framework application using Oracle

One of my colleagues needs an application deployed on a web server. However, the application uses MVC and Entity framework (which are both new technologies for me.)
I have done a straight 'bin copy' deployment. Part of the application seems to function properly, but other parts are not. I believe the application is failing when accessing the database.
Here are the application particulars:
- Visual Studio 2010
- MVC 4
- Entity Framework 5
- Database being accessed: Oracle 11gR1
The machine the application is being deployed on:
- Windows Server 2008 with IIS 7
- An existing Oracle 11.2.0 full client (for use with other applications on the server)
My question: Am I doing this right? Is it necessary to do a separate install of ODAC? And if I do, will it mess up my existing Oracle 11 client?
Yes, you have to install ODAC components on the server.
Please check below link for more info.
Cannot Deploy MVC Project with Entity Framework and Oracle ODAC

Using Oracle DB from C#-VS2005

Oracle installed on the server is 10.2.0.3 Enterprise Edition 64bit (10g).
ODAC is showing version as 10.2.0.2.20 is on a Windows 2008 x64 machine.
Error I run into when I run my app in my test environment in above machine is
The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.
I tried using .Net Oracle namespace and I get this using a version from
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
Error:
Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
Anyone run into such an issue?
Also what is the right Oracle Client/ODAC to use on Windows 2008 x64 machine? Anyonen have a link?
You seem to have installed the 32 bits Oracle client, or you must have a 32 dll masking your 64bits client. You need to install the 64bits client so that 64 bits dll can be accessed by your app. Look for an oci*.dll in your path.
Also look into the registry under hklm\software\oracle to see how many 'homes' you have.
Finally if you have toad on that client look at the home selector in the connection dialog box. It will show incomplete or inoperative homes in red.

Oracle .NET Provider DLL hell

I am currently developing on a Win7-32bits computer. Everything works fine. It's a ASP.NET application.
I was able to use Microsoft's Oracle deprecated .NET provider to connect to Oracle (using 32 bit instant client) and also ODP.NET. No problems at all. Application runs fine.
The problem comes when I deploy it to IIS7 on Windows 2008 Server 64bit computer. I can't get Microsoft's deprecated .NET provider or ODP.NET to work easily.
Is there a straightforward way to use a 32bit based ODP.NET or Microsoft's Oracle deprecated .NET provider in Windows 2008 Server 64bits?
DLL hell here!
Thanks.
Have you tried creating a 64bit version of your software and deploying with the x64 version of ODP.NET?
See this answer for Visual Studio configuration details.
Since this question is unanswered I'll add a link to another answer I created a while ago even though this question is very old.
Is ODP.NET required for Oracle 11g Client?
In general, change to Oracle.ManagedDataAccess (the managed code version of the ODP.NET client made by oracle) instead of the non-managed alternatives. This will help you a lot with "bittyness".
if you set IIS to run 32 Bits then I can confirm that the odp.net driver should work without problem as long as it's the 32 bit client. http://support.microsoft.com/kb/894435.
I've done this in iis for websites in the recent past and for our winforms app have set it to be x86 build so we always get the 32 bit odp providers on a 64 bit os (though you can do it with corflags as well).
Cheers,
Crocked

Resources