Tags: , , | Posted by Kevin Babcock on 5/24/2009 8:04 PM | Comments (8)

Visual Studio Error Message

I ran into this error today when trying to connect to Oracle from within Visual Studio Server Explorer after installing the Oracle Data Access Components, which includes the Oracle Data Providers for .NET. A cursory search of Google yielded no answers, so I was left scratching my head for a few minutes. I’ve connected to Oracle with Visual Studio on my laptop so I knew that this should work. After a bit more investigation, I discovered that there was no entry for the Oracle Data Provider assembly in my machine.config. Usually the provider is registered automatically when installing the Oracle Data Access Components. I’m not sure why it wasn’t added this time.

In order to fix the problem, I first checked that the correct assembly was installed in the GAC (C:\Windows\Assembly).

Exploring the GAC in Windows Explorer

After verify that it was there, I manually added the following DbProviderFactory entry to the machine.config (C:\Windows\Microsoft.NET\<version>\machine.config):

<system.data>
    <DbProviderFactories>
        <add name="Oracle Data Provider for .NET" 
             invariant="Oracle.DataAccess.Client" 
             description="Oracle Data Provider for .NET" 
             type="Oracle.DataAccess.Client.OracleClientFactory, 
                   Oracle.DataAccess, 
                   Version=2.111.6.20, 
                   Culture=neutral, 
                   PublicKeyToken=89b483f429c47342" />
        <!-- Do not remove existing DbProviderFactory entries -->

WARNING: machine.config contains settings that apply to the entire computer. I highly recommend making a backup before applying any changes.

After making the change, I was able to successfully connect to Oracle from Visual Studio Server Explorer again. Problem solved!

Comments

Tanzia on 6/11/2009 2:04 AM Thanks a lot...

Your code and suggestions has helped me a lot.
Alessandro on 6/18/2009 6:13 AM Thank you very much !!
James Moore on 6/27/2009 11:03 AM Hi, thanks for you information.

But I am still facing this issue. What else can I look at? When I click on Test Connection in VS, It tests fine and after that I click OK, I get your screenshot error shown above.

Using Oracle 10g and VS 2008.

1. Checked Windows Assembly
2. Checked machine.config
Kevin Babcock on 7/7/2009 8:44 PM @James: Did you check that the entry in your machine.config matches the installed assembly exactly? Did you also check your app.config/web.config file? If you're still having difficulty, shoot me an email at aggiekevin007 [at] gmail [dot] com.
Wolfgang Weidmann on 7/14/2009 11:11 AM @James: If you're tryin' this on a x64 based Windows you should also add the entry to the machine.config in %windows%\Microsoft.NET\Framework64\<version>\CONFIG\machine.config
Govardhana on 11/10/2009 1:27 AM hi kevin thank u so much for ur post
it really helped me....
Saami Rahman on 12/9/2009 1:40 PM @James: Go back to your machine.config and right after <DbProviderFactories> you will find the code that you have added. At the end of <DbProviderFactories> you will find the same line of code repeated. Delete the line at the end, and try connecting again.

That's what happened to me. I was also getting the error screenshot after applying the fix. Hope that helps!
Pein on 12/14/2009 11:46 AM Hi, after changing the 'machine.config' information, I've got the following error message in vs2008 while adding a coonection :
"An unexpected error occured in the oracle data provider for .Net.Please Contact the provider vendor to resolve the problem"
I've undo changes in 'machine.config' but no use.What should I do? Please respond.Thank You.