Link to home
Start Free TrialLog in
Avatar of Member_2_1242703
Member_2_1242703

asked on

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

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
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

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:
https://www.experts-exchange.com/questions/27020817/The-provider-is-not-compatible-with-the-version-of-Oracle-client.html?&anchorAnswerId=35709210#a35709210
Avatar of Member_2_1242703

ASKER

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?
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.
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.
>>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.
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.
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
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.
Do you have the Oracle 11.2.0.3 client installed?  and the proper bit version?
Steve, are we assuming database version here, or did I miss a previous comment?
You said, "Do you have the Oracle 11.2.0.3 client installed?", and I am not seeing where that database version was mentioned.
>>using Oracle.DataAccess.dll version 2.112.3.0.

The 112.3 correlates to 11.2.0.3 Oracle software version.
I have 11.2 installed on my server, but I didn't know if you were asking me or not.
>>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.
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.
It would be good to know the environment a little better, like what type of application this is.
>>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.
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!!
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?
>>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:
https://www.experts-exchange.com/questions/27020817/The-provider-is-not-compatible-with-the-version-of-Oracle-client.html?&anchorAnswerId=35709210#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.
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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."}
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.
>>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.
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.
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.