I'm doing asp.net mvc3, and I have a problem with ODP.NET, Oracle.DataAccess.
Whenever I try to do my unit test, it throws a FileNotFoundException.
I thought I've installed and been using Oracle.DataAccess v4.112.3.0, but my application keeps looking for 'Oracle.DataAccess, Version=4.121.1.0'.
Still I can find 'Oracle.DataAccess v4.112.3.0' in my GAC and through the FusionLog I found belows in my machine.config. So I guess there are some version conflict of ODP.NET.
<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=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
So, I've tried to modify the version in the machine.config but it didn't work.
Anyone can help me to fix this?
You can always force a specific version with a runtime redirect in web.config (or machine.config), provided the Oracle dll's interface across versions has stayed the same:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/>
<bindingRedirect oldVersion="4.121.1.0" newVersion="4.112.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
From my experience this trick has worked when redirecting from 10.1 to any newer version, but once we ran in mysterious errors when trying to redirect backward (see this), therefore I advise you to better find the exact reason why this is happening - look in your *.csproj which Oracle.DataAccess exactly is referenced and/or disassemble your binaries to inspect also the references of referenced libraries. (It is possible that rather than your code some 3rd party lib you use wants this exact version of ODP.NET).
Related
Using Visual Studio 2013, I've added the latest version of ODP.NET Managed to a project using Nuget:
Install-Package odp.net.managed
http://www.nuget.org/packages/odp.net.managed/121.1.2
Now, when I try to run the following code:
Database db = DatabaseFactory.CreateDatabase();
It throws the following exception:
An exception of type 'System.ArgumentException' occurred
in System.Data.dll but was not handled in user code
Additional information: Unable to find the requested .Net
Framework Data Provider. It may not be installed.
After reading of other users's similar issues, I added the Managed driver section to C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Config\machine.config:
<system.data>
<DbProviderFactories><add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
But that had no affect.
I have the connection string specified as such in my web.config, but I'm not sure if it is even looking at the connection string format as it is failing before I open the connection:
<connectionStrings>
<add name="OneCDPBuild"
providerName="Oracle.ManagedDataAccess.Client"
connectionString="Data Source=database;user id=IDhere;pwd=passwordhere;" />
</connectionStrings>
I added the following to my web config:
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="ODP.NET, Managed Driver"
invariant="Oracle.ManagedDataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
I was getting this error when deploying an ASP.NET MVC 5 application using EntityFramework 5 to our 64-bit server on which the 64-bit version of the ODAC client components were installed.
I followed b_levitt's advise and confirmed that the connection could be opened manually without using the factories, so the ODAC was installed and working, but the factory methods were unable to locate the assemblies.
After pulling my hair for an undisclosed amount of time, I figured out that the problem was with the machine.config file for the 32-bit version of the .NET framework. It did not include the entries for the oracle providers, so I manually added the following entries to this file:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
Under
<configuration>
<configSections>
make sure that you have the following two section entires:
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
You can get the exact entries from your machine.config file under the framework64 folder.
Next, under
<system.data>
<DbProviderFactories>
make sure that you have the following two factory names:
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<add name="ODP.NET, Unmanaged Driver" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET, Unmanaged Driver" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
After adding these entries, everything was working for me.
I would start by doing a direct test and avoiding the factory methods:
var conn = new Oracle.ManagedDataAccess.Client.OracleConnection("your connection string");
conn.Open();
Any issues here will either be related to the Oracle.ManagedDataAccess.dll missing from the bin directory, or connectivity issues caused by the connection string (assuming you can already connect to the oracle instance via other means).
As for the factory, it looks like you're using some out of date enterprise library code. In later versions of the framework I believe you would use:
var factory = DbProviderFactories.GetFactory("ODP.NET, Managed Driver");
var conn = factory.CreateConnection();
I think if you take it one step at a time you'll get better feedback.
I solved mine changing the IIS Application Pool configuration for Enable 32-bit Application to FALSE.
I was getting the exception Failed to find or load the registered .Net Framework Data Provider because the ODAC I installed is for 64-bit, and my app pool was making the app run at 32-bit.
Okay, this one is really puzzling me, and I apologize if the title of the question doesn't accurately describe what my problem is.
I have a program made in C#, using Entity Framework and SQL Server CE. I developed it on Windows 7, and it works fine. I also have a Windows 8.1 machine that I've tested it on, and it works fine on that too.
However, on a few Windows 8.1 computers, the program crashes as soon as it tries to access the database. I get the following error:
Unhandled Exception: System.InvalidOperationException: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.3.5'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Now, this really confuses me, because I have the latest NuGet package for SQL Server CE installed on my project (4.0). I used the SQL Server CE toolbox to explicitly create a SQL Server CE 4.0 database, I distributed the 4.0 dll's with the application, and I explicitly have version 4.0 listed in my app.config file (invariantName="System.Data.SqlServerCe.4.0").
So, why does the error say System.Data.SqlServerCe.3.5? Why does this error only occur on a couple of Windows 8.1 machines?
(I also searched through my entire solution, and the text "3.5" doesn't even appear anywhere.)
I found similar errors, and I tried (from this question) to include this:
private volatile Type _dependency;
public MyClass()
{
_dependency = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
}
Has no effect, I still get the same exact answer.
Anyways, if anybody has any ideas, I would greatly appreciate any kind of input.
I think problem is both SQL Server CE components installed in your system.
My solution :
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.3.5" />
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0"
invariant="System.Data.SqlServerCe.4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
I had the same issue and solved it based on this link.
Find this section in your App.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
And change oldVersion="0.0.0.0-4.0.0.1" to oldVersion="4.0.0.0-4.0.0.1"
Check your config file and add an Entry for the DbProviderFactories like this:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
Take a look at your project references, you may be referencing to the wrong dll
I'm new on this. I got a sample project that runs perfectly on another pc but get an error when running on my own pc. I changed the connection string and restored the database only. I am using a SQLServer connection, but when I run the project it shows a MySQLRoleProvider error. I searched web.config for this configuration but it isn't there. How can I solve this issue?
The message:
`Parser Error Message: Could not load file or assembly 'MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=+++' or one of its dependencies.
<add name="MySQLRoleProvider"
type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=***"
connectionStringName="LocalMySqlServer"
applicationName="/"/>`
You need to install the MySQL Connector binaries first for this to work.
http://dev.mysql.com/downloads/connector/net/
If after installation you still face problems, verify that the dll's are declared in machine.config file of the framework version that you're running.
Add following to config file...
<configuration>
<!--Other omited-->
<system.data>
<DbProviderFactories>
<clear />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=6.6.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<!--Other omited-->
</configuration>
I downloaded MySQL Connector/Net 6.7.4 and MySQL for Visual Studio 1.0.2, and then followed these instructions to test it:
Create a connection to the existing MySQL database.
Create a console application.
Add the ADO.NET Entity Data Model from the existing database connection.
Add Code Generation Item EF 5.x DbContext Generator, replacing the .tt files.
Write some code that retrieved records from the database.
Running the application, I got this exception:
ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider.
Then I added references to the MySql.Data and MySql.Data.Entity libraries version 6.7.4.0 to my .NET 4.5 project. Now when I run the application, I get a different exception:
FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.6.5.0,culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Note the version number, which is not the version of MySQL Connector that I have installed.
How do I get it working correctly?
The trick to solving this was:
Add references to the MySql.Data and MySql.Data.Entity libraries of the correct version (6.7.4.0 for .NET 4.5, in my case) to the project.
Edit machine.config with your editor run as administrator, and replace all occurences of MySQL version 6.6.5.0 by 6.7.4.0.
For the second step, note that there are multiple machine.config files, one for each framework version (3.0, 3.5, 4.0) and architecture (32-bit, 64-bit). Also note that the machine.config file for .NET 4.5 is in the .NET 4.0 folder. You can find the machine.config files in:
C:\Windows\Microsoft.NET\Framework\\Config
And:
C:\Windows\Microsoft.NET\Framework64\\Config
If there are no references to MySQL in the machine.config file, you might not have installed MySQL for Visual Studio. Either do that, or add the following to the app.config file of your project:
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Note however, that when you both install MySQL for Visual Studio and add the above snippet to your app.config file, then you'll get this exception:
ConfigurationErrorsException: Column 'InvariantName' is constrained to be unique. Value 'MySql.Data.MySqlClient' is already present.
I don't like to edit machine.config. Just add this redirect to web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.6.5.0" newVersion="6.7.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Using this should stop the exception that Virtlink mentioned:
<system.data>
<DbProviderFactories>
<remove name="MySQL Data Provider" />
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Especially note the <remove name="MySQL Data Provider" /> line.
Download MYSQL 6.7.4.0 from HERE . Notice that your specific problem requires 6.7.4.0 and NOT other version !
Direct link is this .
Download and add the files to the reference folder of your solution .
This would probably solve your problem (it did for me , and yes , I know this can by a very annoying problem) .
Good luck :)
I realise this thread had an answer back in 2013 but I have just encountered this problem again. In my situation, I recently installed the Windows 10 Anniversary update. Didn't have an issue before this.
As per the answers above, it turns out my Machine.config file had been overwritten (I presume by the update).
For me once I restored the MySql Assembly information to the Machine.config file, it immediately started working again.
In particular the "Runtime" and "DbProviderFactories" sections had been wiped and had to be replaced. They were as follows (these will vary depending on the versions of the assemblies you are using):
Runtime Section:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="6.7.4.0" newVersion="6.9.9.0" />
</dependentAssembly>
<dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="MySql.Data.Entity" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="6.7.4.0" newVersion="6.9.9.0" />
</dependentAssembly>
<dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="MySql.Web" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="6.7.4.0" newVersion="6.9.9.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
DbProviderFactories Section
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
Hope this helps anyone else coming across the same problem.
I'm trying to learn and figure out if it is possible to deploy an MVC, EF, ODAC 11.2.0.3 app to a server that has a previous version of ODP.NET installed. Rather than updating the sever ODP.NET (which I can't), I figured I could use the Oracle Instant Client.
Is this doable?
1) I added these dlls to my project to support Instant Client
-Oracle.DataAccess.dll
-oci.dll
-ociw32.dll
-orannzsbb11.dll
-oraociei11.dll
-OraOps11w.dll
2) Next I updated web.config for the dbProviderFactories
<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=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
3) This (afaik) is how to use the Oracle dll in the bin rathre than the GAC
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" />
<publisherPolicy apply="no" />
</dependentAssembly>
</assemblyBinding>
</runtime>
4) Finally my connectionString
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Oracle.DataAccess.Client;
provider connection string="DATA SOURCE=XXX;PASSWORD=XXX;PERSIST SECURITY INFO=True;USER ID=XXX"" providerName="System.Data.EntityClient" />
</connectionStrings>
This is the error I receive
Unable to find the requested .Net Framework Data Provider. It may not be installed.
I really appreciate any help here. I'm rather new and have a lot to learn. Thanks in advance. cheers
Add a <remove … /> section in the <DbProviderFactories> element in the web config to remove any existing Oracle provider. (before the <add>)
<remove invariant ="Oracle.DataAccess.Client" />
It seems from your question that you need to deploy an update to your application and the new version of ODP.net using only xcopy deployment permission.
Since your application is being changed, then you shouldn't need the assembly binding changes or DbProviderFactories.
Just update the csproj of the class library with your edmx etc to have a reference to the new ODP.net version, eg
<Reference Include="Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86" />
If you get an issue with your tnsnames.ora, then you would have to do one of the following:
a) Add a system environment variable TNS_ADMIN to point to the directory of the tnsnames.ora, or
b) Change the connection string to something based on:
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;
c) See if you can put a copy of the tnsnames.ora somewhere else.
Here is my Xcopy solution.
I posted it over at
(https://jeremybranham.wordpress.com/2011/04/25/oracle-instant-client-with-odp-net/#comment-181)
as well.
But I think I can post my xml without formatting issues here.
Nuget "packages.config"
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.0" targetFramework="net35" />
<package id="EnterpriseLibrary.Common" version="5.0.505.0" targetFramework="net35" />
<package id="EnterpriseLibrary.Data" version="5.0.505.0" targetFramework="net35" />
<package id="EntLibContrib.Data.OdpNet" version="5.0.505.0" targetFramework="net35" />
<package id="Unity" version="2.1.505.2" targetFramework="net35" />
<package id="Unity.Interception" version="2.1.505.2" targetFramework="net35" />
</packages>
app.config
(note the <clear /> tag below. this may or may not be needed, but I figured it was better to clear them out since you don't know what may be in the machine.config file)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataConfiguration defaultDatabase="OracleMainConnectionString">
</dataConfiguration>
<connectionStrings>
<add name="OracleMainConnectionString"
connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyOracleServerName)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MyServiceName)));User ID=MyUserName;Password=MyPassword;"
providerName="Oracle.DataAccess.Client" />
</connectionStrings>
<appSettings>
<add key="ExampleKey" value="ExampleValue" />
</appSettings>
<system.data>
<DbProviderFactories>
<clear />
<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description=".Net Framework Data Provider for Oracle" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<add name="EntLibContrib.Data.OdpNet" invariant="EntLibContrib.Data.OdpNet" description="EntLibContrib Data OdpNet Provider" type="EntLibContrib.Data.OdpNet.OracleDatabase, EntLibContrib.Data.OdpNet, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null" />
</DbProviderFactories>
</system.data>
</configuration>
I am developing on a x64 Windows 7 machine.
I downloaded:
ODAC1120320Xcopy_32bit.zip
(from oracle.com)
Which is the:
ODAC 11.2 Release 5 (11.2.0.3.20) Download the XCopy version [Released September 11, 2012]
I unzipped this zip file.
I searched and fished out these files:
oci.dll
Oracle.DataAccess.dll
orannzsbb11.dll
oraociei11.dll
OraOps11w.dll
Note, when there were 2 files of the same name, I took the "bin\2.x\" or "odp.net20\bin" version for my 3.5 Framework need (I'm not on 4.0 yet).
I took these files, and put them in a subfolder from where my .sln file resides.
.\MySolution.sln
.\MyConsoleApplicationFolder\MyConsoleApp.csproj
.\ThirdPartyReferences\
.\ThirdPartyReferences\Oracle\
I place all the files above in the
.\ThirdPartyReferences\Oracle\
folder
I used "Add Reference" to add a reference to Oracle.DataAccess.dll to the "MyConsoleApp.csproj" csharp project.
(This meant browsing to "..\ThirdPartyReferences\Oracle\" of course)
I used a "Post Build Event" to copy the "extra" (aka, "accessory)" files
My lines in my post build event were:
copy $(ProjectDir)..\ThirdPartyReferences\Oracle\oci.dll $(TargetDir)*.*
copy $(ProjectDir)..\ThirdPartyReferences\Oracle\orannzsbb11.dll $(TargetDir)*.*
copy $(ProjectDir)..\ThirdPartyReferences\Oracle\oraociei11.dll $(TargetDir)*.*
copy $(ProjectDir)..\ThirdPartyReferences\Oracle\OraOps11w.dll $(TargetDir)*.*
Note, my post build event replaces the "Copy if Newer" from the URL instructions above.
When I ran my project........I got a few missing dll errors.
Note:
In the assembly that has your calls to the EnterpriseLibrary.Data objects…you’ll get “Cannot find Microsoft.Practices.SomethingSomething namespace. Just keep adding references to these dll’s (that the above package.config will pull down) until the errors go away.
Like here is a specific one:
"Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
So (after running Nuget of course, to download all the files)
I went and added a reference to:
\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll
That cleared up the issues.
And my csharp code: (note "select *" is for demo purposes only)
/*
using System;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
*/
public IDataReader EmployeesGetAll()
{
IDataReader returnReader = null;
try
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbc = db.GetSqlStringCommand("SELECT * FROM ( SELECT * FROM TEMPLOYEE ) WHERE ROWNUM <= 25");
returnReader = db.ExecuteReader(dbc);
return returnReader;
}
finally
{
}
}
And it worked.
Thank you:
https://jeremybranham.wordpress.com/2011/04/25/oracle-instant-client-with-odp-net/#comment-181
I think this makes ODP.NET an "xcopy" deployment.
I still need to test on a clean machine to be sure.
But its the end of the day..............
================
Additional Information:
Everything above is correct. However, I hit a caveat.
I was using a "Console Application" to test my code.
When you add a new Console Application to visual studio, it DEFAULTS to x86.
As seen here:
http://www.xavierdecoster.com/post/2011/02/15/console-application-visual-studio-gotcha-on-x64-os-aspx
EDIT: (Updated link)
http://www.xavierdecoster.com/post/2011/02/15/console-application-visual-studio-gotcha-on-x64-os
So when I put all the configuration and code and stuff in a real project (which was set to "Any CPU" on a x64 bit machine)...everything I had done stopped working. :<
After tweaking a bit........
I found this file on oracle.com
ODAC1120320Xcopy_x64.zip
I then repeated everything I did above , but searching the unzipped files of this x64 zip file.
Everything is working.
But that "x86" default thing with a Console application threw me for a loop.
I was getting the same error (data provider not found) when deploying ODP.NET via Instant Client. The only thing that I needed to do was to add the following to my exe.config file (inside the tag)
<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=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>