Deploying C# web application connecting to an Oracle database - visual-studio-2010

As we tried to deploy a new project that connects to an Oracle database, we encountered some problems..
On my development workstation, I have my Oracle dll's installed in c:\app\oracle\product\11.2.0\client_1\BIN but on the development web server, it's in stalled in c:\oracle\product\11.2.0\client_1\BIN (noticed NOT in the app folder).
When an application is deployed, those dll's that are referenced need to be in the same location on both machines. So needless to say, we get an error from the development server.
In order to fix this, we tried a few things -
Move the Oracle install to c:\app... on my machine and rebuild from my development machine. This didn't work because there are relative dll's that rely on that path.
Because 1 didn't work, we tried to reset the environment path variables to c:\oracle on my machine. That didn't work.
tried to copy the needed dll's into my bin directory because my understanding is Visual Studio will build from the GAC, then from the bin directory. That didn't work.
Knowing that re-installing Oracle on the development server to c:\app\Oracle isn't an option, has anyone else come across this problem?

You need to make sure that your Oracle install is setup correctly. I have a few utilities that can assist with this.
Step 1 -
The utilities below will confirm first that .net works with Oracle on your server
http://tsells.wordpress.com/2010/02/18/oracle-connection-tester-for-net-applications/
Step 2 -
If the utility above worked - then go to step 3. Otherwise - .net can't see oracle on this machine. Check your path statement first - make sure the oracle bin directory is pointing to is the correct one. If not - change it and try again.
If this doesn't work - I recommend uninstalling oracle completely and reinstalling. Use the following steps.
Stop any services (start - run - services.msc) below that are running
oracle mts recovery
Distributed Transaction Coordinator
Delete all oracle directories from the file system (C:\app, C:\Program Files | C:\Program Files (x86(
Remove Oracle entries from the system path
Remove any Oracle entries from the environment variables (if they exist) such as ORACLE_HOME
Open the registry editor (start -- run -- regedit) and remove any oracle entries from the following key
HKLM\Software\
HKLM\Software\Wow6432Node (64 bit machines only)
Empty Recycle bin (makes me feel better) :)
Reboot the machine
Download one of the two items
Oracle Client Installation (full)
ODAC (Oracle Data Providers)
Install them (make sure if you choose the client version - you use a minimum of the runtime install) - do NOT use the instant client - it never seems to work properly.
Copy the TNSNames.ora file over
Test with the utility again. It should be successful.
Step 3 -
If the utility above worked - then you need to make sure the bit level of your application matches the bit level of the Oracle client installation. For the app - this will be the bit level of the application pool.
Notes - the oracle.dataaccess.dll file in the bin folder is used to help create the images (ngen, aspnet compilation). Once you attempt to call the oracle data provider for .net - it is routed to your client installation to perform the actually data access.

Related

remove oracle multiple home

I don't know what I did. I accidentally installed multiple Oracle on my machine. It could have been that I did not realize I installed successfully. I end have 5 Oracle home folders
anyway, I kept having problem connecting to Oracle. SQL developer works, but sql/plus and C# have not been working.
There is a chance multiple Oracle Home cause the problems. I don't know. I decide to uninstall and reinstall again and see what happen
I run deinstaller. It removes successfully on dbhome_5 folder. The files in dbhome_5 folder still exist, I cannot uninstall Oracle in other 4 folders
dbhome_1
dbhome_2
dbhome_3
dbhome_4
Deinstaller could not detect anything. Therefore, I cannot uninstall
Those 5 instances still exist.
I can install against. That mean dbhome_6. I don't know it will create confusion again.
How to uninstall / completely remove Oracle 11g (client)?
This page tell us how to clean remove. I don't to do uninstall because I cannot. Do I have to manually remove all the files?
I just want the machines to have clean environment before the next installation
I have the feeling that was what happened before. I fail to configure. I uninstall. Then I have 5 folder
I am using Oracle 11 universal installer version 11.2.1.0
Thanks
Having done this before myself, I know how confusing it can get.. worse even, that the configuration for different oracle data access clients about which home to use can be in different places, so your sql plus can end up using one install whereas your c# is using another
I'd recommend to follow the manual removal instructions you found on the linked page; do it for every oracle home you can find (search your entire drive for e.g. tnsnames.ora)
Remove everything (maybe preserve any tnsnames you find as it will make configuring the reinstall a bit easier) and then reinstall it, just once this time:)

How can I completely uninstall oracle 11g?

How can I uninstall Oracle 11g from my laptop? The uninstall program that comes with the software doesn't completely uninstall all the components. I tried it with Oracle12c and it left a lot of programs. I tried to delete the files manually but some dll files in the BIN directory were are not accessible. I want to do the right thing with 11g. Any suggestions?
Thank you very much in advance.
There are some problems when I uninstall Oracle 11g (on Window 10) from my installed path "D:\app\" .This is my solution to remove oracle manually:
Delete D:\app{user}\product\11.2.0\dbhome_1
and all Oracle's files from D:\app\
If you can not delete these files, need to change the owner or add permissions
Properties>Security> Advanced> Change Owner> Advanced>Find now> Choose Users
Sometime you need to add permissions to Users: Properties>Security>Edit> Add Users> Allow ...
Delete C:\Program Files (x86)\Oracle, C:\Oracle
Delete C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Oracle -
OraDb11g_home1
Run regedit.exe>
delete HKEY_LOCAL_MACHINE/SOFTWARE/Oracle
delete HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ORACLE
Delete HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Ora*
Start Run>Computer Management> System Tools>Local Users and Groups> Delete
all Oracle's users and groups
Restart windows.
Hope helpful for you!
First of all you should use the deinstall tool as recommended by Oracle.
Then if this fails have a look at this document: Manually Removing the Remaining Oracle Database Client Components (11.1), it provides detailed instruction how to remove everthing.
This documentation is for Oracle Client 11.1, however the principle should be the same for 12c. Actually the documentation for 10.2 is even more complete: Manually Removing the Remaining Oracle Database Client Components (10.2)
Perhaps some files are locked and you can not delete them by default, for example file oci.dll. Solution is to rename the file, e.g. oci.dll_x and then reboot your PC. After reboot you can delete the file.
Note, in case you installed 32-bit Oracle the Registry key is HKLM\SOFTWARE\Wow6432Node\ORACLE\... instead of HKLM\SOFTWARE\ORACLE\...
Before deinstalling oracle software, make sure you have deleted the oracle databases (and other services) running from the ORACLE_HOME
I have written about the different methods in which you can remove Oracle software from Linux server:
Using deinstallation tool with runInstaller
Using deinstallation tool under ORACLE_HOME
Manual Oracle uninstall

VB 6 legacy app migration to Oracle 11g

I have a legacy VB (visual basic) 6 application that connects to Oracle 8 database. We have to migrate this to Oracle 11g. (Heads up: I have never worked on VB)
The application is shipped to 1000+ users as an EXE file. Here is what i need help on:
For Developers, I understand they will need to install new oracle client for the ODBC drivers and once they test their application on 11g. Once they are done they will publish a new EXE file.
Users, Will install this new EXE file but will this be sufficient ? or the users will need to install something extra other than the new application (like a oracle 11g client, DLL files etc) on their end as well ?
Can a VB 6 app be packaged in such a way that it copies all the DLL/dependencies along with it so that end users do not need to install anything else ?
-- Vivek
I can't believe the previous developers just copied the EXE file! I know that the run-time is installed on most recent versions of Windows, but that is ridiculous!
You can use VB6's "Package and Deployment Wizard". Why not try it out? It will pick up all components contained in the References and Components dialogues, and any DLLs referenced in a Declare statement. However, if those components have dependencies, you might have to add them manually.

How to tell System.Data.OracleClient to use the 64 bit Oracle Driver

I am trying to run a .NET application which uses System.Data.OracleClient on a Win7 x64 workstation. The workstation has a 32bit Oracle client installed, which leads to the following error message:
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.
So this is my long journey of tries and failures:
I tried to install the Oracle client win64_11gR2_client. But during the setup process it crashes without any comment.
I followed an answer from a different SO thread, tried and extracted the instantclient-basic-windows.x64-11.2.0.2.0, and put the folder containing the binaries in the windows PATH variable. I still get the same error message though (even after rebooting).
I followed the "alternative way" from this answer and copied the files oci.dll, orannzsbb11.dll, and oraociei11.dll into the bin/ folder of my web site project. Still the same error message.
I tried and copied all files from the instant client into that directory and tried again, without success.
I installed ODAC112021Xcopy_x64.zip and put the installation folder and the bin folder in the windows PATH variable. No success.
I put my hope on this answer and reviewed the DllPath in the registry (which is actually supposed to relate to ODP.NET as opposed to System.Data.OracleClient) and saw that DllPath points to the correct x64 installation of ODAC, so, if my application wasn't using System.Data.OracleClient, it should work,b but since it does use that, it still failed.
I googled and stackoverflew but didn't find anything else that the posts I already referred to.
I carefully crafted this SO question in the hope of getting any insightful advice from an enlightened SO user.
After getting the first answer from b_levitt, I tried and added the following lines to the Global.asax at Application_Start:
Environment.SetEnvironmentVariable("ORACLE_HOME", #"C:\OracleProducts\Odac-11.2.0.2.1-x64");
Environment.SetEnvironmentVariable("PATH", #"C:\OracleProducts\Odac-11.2.0.2.1-x64;C:\OracleProducts\Odac-11.2.0.2.1-x64\bin");
C:\OracleProducts\Odac-11.2.0.2.1-x64 is where I installed the ODAC 64 bit xcopy version. No success either.
On a related note, I even tried to force my .NET app into 32bit mode without success, but that's a different thing. I need a forward-looking solution, which means 64bit.
Your #5 should have worked but you also need to set the ORACLE_HOME environment variable. I've done this many times including recently with the very xcopy install that you are using. Please check out my experience with the xcopy install and let me know what kind of additional errors that you get.
In my case I was setting it up for asp.net, but winforms is even easier. You can open a cmd window, use the "set" command to set both the PATH and the ORACLE_HOME environment variables and then run your app from that same cmd window. Once you get the bugs worked out, you can use the Environment.SetEnvironmentVariable to set these within your code.
For the record, I do avoid installing the oracle client on client machines by handling all of the business logic via web services. That way I only need the oracle components on the web server.
I had the same problem you have. I found most of my answers through Oracle forums and here at stackoverflow. I can't post links for reference but I can give you some things to try out.
Also include OraOps11w.dll in your bin directory along with the other Oracle dll files.
Go to the project properties|Reference Paths, add C:\Windows\Microsoft.NET\Framework64\v2.0.50727 or C:\Windows\Microsoft.NET\Framework64\v4.0.30319 to the Reference paths depending on which framework version the project is using.
**Fuzzy part that I don't remember well: Remove the System.Data.OracleClient current reference and add the new reference from C:\Windows\Microsoft.NET\Framework64\v2.0.50727 or C:\Windows\Microsoft.NET\Framework64\v4.0.30319 to the Reference paths depending on which framework version the project is using.
See if the exception goes away.
FYI, Microsoft is dropping Oracle data provider (in ADO.NET) support in the near future. It currently works through .NET 4, but it is a good idea to start testing the native Oracle drivers.

Why doesn't ODP.NET 11 xcopy deployment work on a machine with Oracle DB 10 installed?

I have an app that uses a local version of ODAC 11 below the directory that the .exe file is in. The idea is that we want our app to use the local ODAC 11 regardless of what else the user has installed on her machine.
Oracle.DataAccess.dll is in the same directory as the .exe.
It works fine when the client machine has no Oracle client installed, but I get an error when starting it on a machine with Oracle Database 10.2.0.something installed:
The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.
[Stack Trace]
The provider is not compatible with the version of Oracle client
OracleException
at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleConnection..cctor()
I'm guessing that this has something to do with the runtime binding policy, but a search for "Oracle/ODAC/ODP.NET runtime binding policy" on Google has not turned up anything useful.
Does anyone know how to resolve the issue?
If not this specific issue, can someone point me towards an overview of how to do what I want to do: make sure that my application uses the ODAC 11 no matter what?
So as I understand it, the issue was that while Oracle.DataAccess.dll was in the same directory as the app, it could not find its lower-level homies (oci, et al), hence the compatibility error.
Turns out that if you want an application to work with ODAC 11 xcopy deployment regardless of what else the user may have installed on her machine, you need to do 2 things:
Set the PATH environment variable for the process. (I was already doing this.)
Set the ORACLE_HOME environment variable for the process. (I was not doing this.)
Environment.SetEnvironmentVariable("PATH", Environment.CurrentDirectory + "\\oracle\\11.1\\odac;" + Environment.CurrentDirectory + "\\oracle\\11.1\\odac\\bin;", EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("ORACLE_HOME", Environment.CurrentDirectory + "\\oracle\\11.1\\odac", EnvironmentVariableTarget.Process);
EDIT: It's also important to note that Oracle will throw this error not just for environmental issues, but also if one of the files is missing on the target machine. I got this same error on other machines despite the Environment settings because I had Subversion set to ignore directories called "bin", so the OraOps DLL was not being copied to the client.
An article titled "Deploying ODP.NET with Oracle Instant Client" found at http://alderprogs.blogspot.com/2009/04/deploying-odpnet-with-oracle-instant.html gave what was for me about the best explanation of how to deliver a stripped down xcopy type deployment with your application. Only 5 Oracle DLLs required for support.
That said the answers by ObiWanKenobi and Josh Kodroff provides important additional info which matches with my experience.
Add to that: http://www.brothersincode.com/post/Oracle-ODPnet-xcopy-deployment-for-aspnet.aspx
You want to force your ODP.NET drivers to use the copy of oci.dll that is in your local folder, instead of the one already installed.
You can force this by either
setting the PATH variable so the system finds your copy of of oci.dll first (as in the answer by Josh Kodroff)
or
you can use ODP.NET configuration section in app.config (or web.config) to explicitly set the value of "DllPath".
For details, see http://ora-00001.blogspot.com/2010/01/odpnet-minimal-non-intrusive-install.html and http://database.in2p3.fr/doc/oracle/Oracle_Database_11_Release_1_(11.1)_Documentation/win.111/e10927/featConfig.htm
If you're using oracle client 10.2.0.1 or 10.2.0.2, Oracle Note 215255.1 indicates that if you apply patchset 10.2.0.3 it fixes the issue. Get the 10.2.0.3 database patch (852MB) and patch the client home. Yes, it's the full database server patchset, but it applies to the client as well.

Resources