ODP.NET Managed driver issue

Posts   
 
    
Posts: 26
Joined: 11-Apr-2012
# Posted on: 27-Feb-2014 17:16:25   

Hi, I'm having issues using the ODP.Net Managed driver. When we try to run it on a machine without an Oracle client installed (WPF, .NET Framework 4), we get the following error:

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

It looks like the un-managed provider is still being used? Here's some exception information:

I'm referencing the Oracle.ManagedDataAccess dll, and here are some runtime versions of the llblgen dll's:

SD.LLBLGen.Pro.DBDrivers.OracleDBDriver_MSOracle v4.0.30319 SD.LLBLGen.Pro.ORMSupportClasses v2.0.50727 SD.Frameworks.Validation.LLBLGenPro v4.0.30319

Maybe I'm just not understanding properly but I shouldn't need an Oracle client installed with the Managed provider correct ?

Also I have this in my app.config:


<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>

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Feb-2014 21:43:17   

Did you check the tips in the following thread? https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=22508

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 28-Feb-2014 11:25:26   

Make sure your application runs on .NET 4 or higher. If it runs on .net 3.5, the managed provider can't be used and the dqe switches to the normal odp.net

Frans Bouma | Lead developer LLBLGen Pro
Posts: 26
Joined: 11-Apr-2012
# Posted on: 28-Feb-2014 15:24:54   

Thanks guys, yeah it's on .NET 4 - everything seems as it should to me, so I'm not sure what might be going on. I'll keep toying with it - any other suggestions you might have would be appreciated. Thanks Mike

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Mar-2014 06:00:11   

Check if you are doing this right (from http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=22508&HighLight=1): 1. The Oracle.ManagedDataAccess.dll should exist in the same directory as the code is executed from. (CopyLocal=true?) 2. TnsName.ora should also be in this folder. 3. Add the provider in your config.

David Elizondo | LLBLGen Support Team
Posts: 26
Joined: 11-Apr-2012
# Posted on: 03-Mar-2014 15:35:31   

Yeah, that was referenced above as well.. all good on that front. Is there anything else that could cause it to not choose the managed driver ?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 03-Mar-2014 19:46:28   

Please provide the correct LLBLGen Runtime library version/build no. More details here: https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7719

Please check the following link, for possible helpful info. http://docs.oracle.com/cd/E48297_01/doc/win.121/e41125/InstallODP.htm

Posts: 26
Joined: 11-Apr-2012
# Posted on: 13-Mar-2014 22:48:16   

Sorry for the delay, I'm using LLBLGen Pro v4.1, runtime version 4.1.14.219, I'm also now using the 4.5 .NET Framework.
I'm connecting to the following Oracle database: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0

Here are some snippets of code to show how I am connecting/retrieving data. Basically in a WPF form a user gets to select an entry from their TNS names file (which they must have a TNS_ADMIN environment variable setup pointing to the location of the file) and that is the connection that will be used. Maybe I'm going about this entirely the wrong way, I don't know.

Any insight would be appreciated.. Thanks!


// 1.  Build list of Oracle servers for user to select...

string ProviderName = "Oracle.ManagedDataAccess.Client";
DbProviderFactory factory = DbProviderFactories.GetFactory(ProviderName);

if (factory.CanCreateDataSourceEnumerator)
{
    TNSEntries = new ObservableCollection<TNSEntry>(); // TNSEntry is a simple class with TNS information (server, port, etc.. anything in a TNS file)
    DbDataSourceEnumerator dsenum = factory.CreateDataSourceEnumerator();
    DataTable dt = dsenum.GetDataSources();
    foreach (DataRow row in dt.Rows)
    {
        TNSEntry t = new TNSEntry(row[0].ToString());
        t.ServerName = row[1].ToString();
        t.ServiceName = row[2].ToString();
        t.Protocol = row[3].ToString();
        t.Port = row[4].ToString();

        TNSEntries.Add(t);  
    }
}

// 2.  Set connection string info based on server picked by user in a dropdown ... 

OracleConnection OraConnBW = new OracleConnection();
_DataAccess = new DataAccessAdapter();
foreach (TNSEntry t in TNSEntries)
{
    if (t.InstanceName == Args[0]) //Args[0] is the Oracle server picked by the user..
    {
        _DataAccess.ConnectionString = "Data Source=" + t.InstanceName + ";User Id=apps;Password=" + Args[1] + ";";  //Args[1] is password entered by user...
    }
}


// 3.  Example usage with specified connection ... (this will error as specified in my orig. post if no oracle client is installed)

try
{
    LinqMetaData L = new LinqMetaData(_DataAccess);
    var resps = (from r in L.XxmscRespAndAppsV where r.ApplicationName == "Payables" select r).ToList();
    foreach (var r in resps)
    {
        ResponsibilityList.Add(r.ResponsibilityName);
    }

    var flexs = (from r in L.XxmscFlexStructureV select r).ToList();
    AcctFlexList = new ObservableCollection<string>();
    foreach (var f in flexs.OrderBy(x => x.IdFlexStructureCode))
    {
        AcctFlexList.Add(f.IdFlexStructureCode);
    }

    worker.ReportProgress(1, "Connection OK");
    e.Result = OraConnBW;

}
catch (Exception ee)
{
      worker.ReportProgress(1, ee.Message + Environment.NewLine + "Outer Exception:" + ee.StackTrace + Environment.NewLine + "Inner Exception: " + ee.InnerException);
}
    

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Mar-2014 11:29:21   

What's 'OracleConnection' ? This suggests you referenced the ODP.NET provider ? There's no work done with OraConnBW, why is it created? It looks you you're caching the DataAccessAdapter instance, correct? Don't do that, create one each time.

(edit) I think I see what you're doing: you use the MS Oracle DQE, while you should use the ODP.NET DQE, correct? System.Data.Oracle is Microsoft's own provider (which is deprecated) and which requires the oracle client to be present. The managed provider is from Oracle itself, and shipped in the ODP.NET 12c package.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 26
Joined: 11-Apr-2012
# Posted on: 17-Mar-2014 13:59:44   

Yep, it was as simple as that simple_smile Works great now. Thanks!