2

My question is remarkably similar to this: Oracle .Net ManagedDataAccess Error: Could not load type 'OracleInternal.Common.ConfigBaseClass' from assembly

However, there are two reasons why I'm not going with the consensus.

1) I'm not sure it would work. I don't know a lot about the GAC, but I looked in the assemblies folder and there isn't a copy of Oracle.ManagedDataAccess with version 4.121.2.0. All the Oracle.ManagedDataAccess assemblies begin with 2.

2) I'm only getting this error on the production server, and I (as a lowly dev) don't want to take any action on the production server that could affect the multitude of applications it houses.

This is my stack trace:

Failure: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
---> System.TypeInitializationException: The type initializer for 'Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices' threw an exception. 
---> System.TypeLoadException: Could not load type 'OracleInternal.Common.ConfigBaseClass' from assembly 'Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342'.
   at Oracle.ManagedDataAccess.EntityFramework.EntityFrameworkProviderSettings.Oracle.ManagedDataAccess.EntityFramework.EFProviderSettings.IEFProviderSettings.get_TracingEnabled()
   at Oracle.ManagedDataAccess.EntityFramework.EFProviderSettings.InitializeProviderSettings[T]()
   at Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices..ctor()
   at Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices..cctor()
   --- End of inner exception stack trace ---
Community
  • 1
  • 1
Eleanor Holley
  • 691
  • 1
  • 7
  • 27
  • How did you look into assemblies folder? When you use Windows Explorer you see only .NET 2 assemblies, see http://stackoverflow.com/questions/3054304/gacutil-exe-successfully-adds-assembly-but-assembly-not-viewable-in-explorer-w Use `gacutil` instead. – Wernfried Domscheit May 18 '17 at 14:36
  • @WernfriedDomscheit Yes, I used Windows Explorer. Thank you! – Eleanor Holley May 18 '17 at 14:39
  • Are you sure? As far as I know `Oracle.**Managed**DataAccess` does not exist for .NET2. I think you missed it with `Oracle.DataAccess` `Oracle.ManagedDataAccess` and `Oracle.DataAccess` are completely different! – Wernfried Domscheit May 18 '17 at 14:41
  • I think you've fallen victim to DLL precedence if you're using the Managed driver. http://stackoverflow.com/questions/1606273/net-assembly-loading-priorities – CDove May 18 '17 at 14:48
  • @WernfriedDomscheit You're correct. I misread the names. – Eleanor Holley May 18 '17 at 14:53

1 Answers1

1

The problem is that the server is using a different version of the Oracle Client than you are. I run into this often. The only solutions I've found are either to ensure I'm using the DLL that is used by the server, or updating the server to my version of Oracle Client. As long as the other version is lurking in the GAC, your local version is likely to be ignored.

CDove
  • 1,940
  • 10
  • 19
  • Oracle.ManagedDataAccess should be independent from any Oracle Client installation. – Wernfried Domscheit May 18 '17 at 14:38
  • You'd think, but in environments where different versions of OracleClient are being used, I've seen plenty of situations where the ODP.Net DLL will be ignored or just flat bomb if the version of Oracle Client is too old. I now actually keep a copy of the DLL in use on a specific server in a named folder so when I need to reference for a project deploying to that server, I use the DLL in the server's GAC. – CDove May 18 '17 at 14:41
  • Again Oracle.**Managed**DataAccess does not use any Oracle Client at all. – Wernfried Domscheit May 18 '17 at 14:44
  • That's not a bad practice to get into anyway if you're in a corporate environment where they are slow to roll out updates to anything ever. It may, but what Wernfried said is correct. If you're using the *Managed* dataaccess, remember that the GAC will take precedence. http://stackoverflow.com/questions/1606273/net-assembly-loading-priorities – CDove May 18 '17 at 14:48
  • @CDove So if I find the Oracle.ManagedDataAccess used by the server and copy it into my app, it will run correctly? And a follow-up: Where would I find that? Thanks for your help. – Eleanor Holley May 18 '17 at 14:49
  • No. More along the lines of, find the version that is used on the server, bring it back to your project, and update all of your references to use it. Fix what it breaks, deploy after that, and you should be solid. – CDove May 18 '17 at 14:57