[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

.NET 4.0 VS2010 Oracle.DataAccess on 64bit Windows Server 2003

Posted on 2012-08-24
28
Medium Priority
?
7,493 Views
Last Modified: 2012-08-31
I have a program I wrote that access an Oracle DB. In my development environment, the CODE WORKS PERFECTLY. However in the environment in which I want to run the program on, it does not run. It does not return an exception because it never actually makes it to my code. It is an issue with the environments compatibility with the Oracle connection from my application. When I comment out the following:

'Imports Oracle.DataAccess.Client

'Dim myConnection As OracleConnection = New OracleConnection()

            'myConnection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & ConfigurationSettings.AppSettings("oracleServer") & ")(PORT=" & ConfigurationSettings.AppSettings("oraclePort") & ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" & ConfigurationSettings.AppSettings("oracleID") & ")));User Id=myid;Password=mypass;"
            'connstring = myConnection.ConnectionString

                'Dim myCommand As New OracleCommand
                'myConnection.ConnectionString = connstring
                'myCommand.Connection = myConnection
                'myCommand.Connection.Open()
                'myQuery = System.IO.File.ReadAllText(ConfigurationSettings.AppSettings("subQuery"))
                'myCommand.CommandText = myQuery
                'myCommand.ExecuteNonQuery()
                'myConnection.Close()
                'myConnection.FlushCache()
                'myConnection.Dispose()
                'myCommand.Dispose()
                'myQuery = ""

Open in new window


Its runs perfectly. With that code in place, (again...NO EXCEPTIONS), I receive the following in the event viewer...

EventType clr20r3, P1 d3d4_testresultload.exe, P2 1.0.0.0, P3 5037e1c7, P4 oracle.dataaccess, P5 2.112.3.0, P6 4ede75f9, P7 877, P8 1ec, P9 oracle.dataaccess.client.oracle, P10 NIL

I'm developing on a 64bit Windows 7 machine with Visual Studio 2010 and the problem is occurring on a 64 bit Windows Server 2003 box.

I have tried a .NET 4.0 and 4.0.2 complie. I have tried it on settings for AnyCPU and x64.

I did notice that the platform is set to Active (x86) and there is no other value in the drop down.

Has anyone else run into this issue?

TIA
0
Comment
Question by:Mike Miller
  • 12
  • 9
  • 6
  • +1
28 Comments
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38331454
Check your ODP.Net versions.  Typically they must match EXACTLY between the server it is compiled on and the server it runs on.

You have a little ability to change version in your app.config.

Check the link below.  I've never tried this but trust the Expert that posted it:
http://www.experts-exchange.com/Database/Oracle/Q_27020817.html?#a35709210
0
 

Author Comment

by:Mike Miller
ID: 38349950
Update...
I installed VS 2010 on the machine in question and the problem has been resolved. However, this isn't really a practical solution. Any ideas on how I can figure out what it was that happened via the install that would have fixed it?
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38350195
There was likely a driver or some GAC config that the install did.

I agree that installing VS on the machine isn't a good idea.  I would have liked to continue troubleshooting this before you did that.  I'm afraid the uninstall will leave stuff behind and never really be truly removed.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Mike Miller
ID: 38351046
I did this on a box I created just to test this error. I still have the original setup if you want to give it a go.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38351081
>>I still have the original setup if you want to give it a go.

Cool.  I'll do what I can and that includes sending out a call for help from the other Experts.  I will go ahead and do this.

In looking again at the Event text, everything points to an unhandled exception fro mthe code.  Since a VS install makes it go 'away', it is likely a config issue.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38352027
What is the full version of Oracle.DataAccess.dll are you using?  The version number should be 4.x for .NET 4.0 applications, although 2.x versions will work just as well.  

There is a separate folder for GAC 32 and GAC 64:

C:\Windows\Microsoft.NET\assembly\GAC_32

     and

C:\Windows\Microsoft.NET\assembly\GAC_64

Just because you are on a 64-bit machine, doesn't mean that the process will run as 64-bit.  You can look in the Task Manager, under the Processes tab.  All processes started as 32-bit will have *32 next to the name.
0
 

Author Comment

by:Mike Miller
ID: 38352062
I am using Oracle.DataAccess.dll version 2.112.3.0.

The dll is actually in the bin/Debug directory of the application.

There is no *32 next to the Image Name in the Task Manager
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38352084
The 2.x assemblies are typically installed in a different folder from 4.x assemblies (the old GAC).

This is the folder for my 2.112.1.0 assembly.

C:\Windows\assembly\GAC_64\Oracle.DataAccess\2.112.1.0__89b483f429c47342

If you try to open this folder in Windows Explorer, there is a special behavior that prevents you from seeing the exact folder.  You will need to look with a Command Prompt.

Are you using TNS connection strings in the config file?  That is typically stored in a TNSNAMES.ora file.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38352088
Do you have the Oracle 11.2.0.3 client installed?  and the proper bit version?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38352100
Steve, are we assuming database version here, or did I miss a previous comment?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38352125
You said, "Do you have the Oracle 11.2.0.3 client installed?", and I am not seeing where that database version was mentioned.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38352150
>>using Oracle.DataAccess.dll version 2.112.3.0.

The 112.3 correlates to 11.2.0.3 Oracle software version.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38352158
I have 11.2 installed on my server, but I didn't know if you were asking me or not.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38352174
>>but I didn't know if you were asking me or not.

Sorry.  No I was asking mwmiller78.  It is sort of a continuation of my very first post thinking it might be a simple version issue.
0
 
LVL 11

Expert Comment

by:b_levitt
ID: 38352816
The part that concerns me with this is that no exception is being thrown.  If this is a windows service then check this article out regarding catching startup exceptions and writing them to the event log.  I've also purposely put a Thread.Sleep() in the service startup so I have time to attach a remote debugger before startup is complete.  I'm sure there's a simple answer to this expecially since you've isolated the issue to your oracle call.  But without the error that's occuring, there's going to be a lot of shots in the dark.

FYI, the ODAC installed on the server does not need to be the exact version, just a later version.  Publisher policies are installed to redirect references to earlier versions.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38353629
It would be good to know the environment a little better, like what type of application this is.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38353927
>>FYI, the ODAC installed on the server does not need to be the exact version, just a later version.

It has been my experience that Oracle doesn't like mixing versions of Oracle.DataAccess.dll and the client installed nativly.  I almost always get a version exception.

The only way I know to tweak it is in the app.config.  I will defer to the .Net Experts if this isn't always the case.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38354200
I wouldn't say that I was an Oracle expert, but I would say that I was a .NET expert.  We have had problems with mixing versions, but that doesn't mean that I am doing everything just right.  Oracle requires quite a lot of knowledge to get "just right".

I was excited to hear about a managed client, though!!
0
 

Author Comment

by:Mike Miller
ID: 38354738
Ok sorry for the delay...

After playing around some more, reading event logs, etc. it turns out that the VS2010 installation did NOT solve my issue. It did however give me more insight into what's going on.

First off...I don't think I have the proper ODAC installed. I just checked and the version I have is 11.2.0.2.1

Additionally, now that I have VS2010 installed I can see the InnerException which is:

{"The provider is not compatible with the version of Oracle client"}

So can I assume that if I update ODAC (or change the DLL) that my issue will be resolved?
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38354766
>>So can I assume that if I update ODAC (or change the DLL) that my issue will be resolved?

Either upgarde the ODAC or copy the Oracle.DataAccess.dll of the verion you have installed into your bin folder and recompile.

Versions need to match, down to the last number, or play with the app.config.

The app.config part I've never tried but another Expert on the site, that I trust, posted what you need to do here:
http://www.experts-exchange.com/Database/Oracle/Q_27020817.html?#a35709210

Recently another Expert posted this 'kludge' for an Oracle install.  You copy 5 of the client files locally into the Bin folder.

I'll see if I can find that link and post it.
0
 
LVL 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 1600 total points
ID: 38354784
Here is the other way.  It is actually in a few links here:

http://www.experts-exchange.com/Database/Oracle/Q_23861097.html
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_27443843.html?#a37123397



I've done it with a simple console app and had to copy the files into the same folder as the .exe but it seemed to work.
0
 

Author Comment

by:Mike Miller
ID: 38355052
Per one of those articles, I copied the correct version of Oracle.DataAccess.dll and the supported files to the directory my exe is in. I then removed the reference to Oracle.DataAccess.dll and created a new reference to the DLL in the same folder as my exe. Still works great on my dev machine. Copied everything over, nope.

For grins, I created an entirely new project. I copied each file in question one by one, ensuring each was the correct version. Created my project, deleted everything on the problematic server related to the old project, tested the new project on my dev machine (works great), copied everything over and...

{"An error occurred creating the form. See Exception.InnerException for details.  The error is: Could not load file or assembly 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format."}

and the inner exception is

{"
Could not load file or assembly 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format."}
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38355079
I've never seen that error.  Check the Bit versions.

If the compiled app and Oracle drivers are the same, see if the app was compiled as 'AnyCPU'.  It might be you are running the 32Bit Oracle drivers and the app thinks it should be running 64Bit.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38355092
>>Version=4.112.2.0

I just noticed this.  In previous examples you were usint .Net 2 drivers.  This one is .Net 4.  Make sure when you copied the files the .Net version specific ones all came from the same version.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 38355141
Make sure the Oracle.DataAccess files are in these folders:

C:\Windows\Microsoft.NET\assembly\GAC_32
C:\Windows\Microsoft.NET\assembly\GAC_64

If not, there is a separate install for ODP.NET version 4.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38355157
Just to clarify:

Will they need to make sure the 64Bit dll is in GAC_64 and the 32Bit dll in GAC_32?

I'm also thinking that if you use the 'copy 5 files locally', they don't need to be in the GAC.  At least in my console app test they didn't.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 400 total points
ID: 38355200
1) 64-bit DLL in GAC_64 and 32-bit in GAC_32

2) The correctly assembly will be resolved for the platform set for the entry assembly.  An example would be w3wp.exe for IIS, when the application pool is set to 64-bit assemblies.

3) Files can be copied locally, but if you have multiple applications on the same server, then you need multiple copies.  This does give you the ability, though, to have multiple versions, depending on application requirements.
0
 

Author Comment

by:Mike Miller
ID: 38355230
If the compiled app and Oracle drivers are the same, see if the app was compiled as 'AnyCPU'.  It might be you are running the 32Bit Oracle drivers and the app thinks it should be running 64Bit.

This is what it was. I had it set to AnyCPU. I switched it over to x86 and it seems to be running fine now. I'm going to put it on the production box and see what happens.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question