Could not load file or assembly 'System.Data.OracleClient

I am currently trying to debug an 2.0 project with a c# code behind, without receiving errors, in Chrome through Visual Studio 2012. The solution was originally created in VS 2005 and upgraded/imported it into VS 2012. However, I am encountering this error when I attempt to run the solution:

Could not load file or assembly ‘System.Data.OracleClient, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have added references to System.Data.OracleClient to each of the projects within the solution, but this has not resolved the issue. Additionally, I have checked the GAC (Global Assembly Cache) for a reference to the assembly (System.Data.OracleClient); it is present. I have also added a reference to the assembly (<add assembly=“System.Data.OracleClient, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089” >) to the web.config file for version 2.0 of .Net (C:\WINNT\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config). I noticed that the project seems to look for the dll in the bin folder of the solution, so I have copied the dll from the GAC to the bin. None of the above steps have resolved the issue. I continue to receive the same error message when the solution is debugged. Any answers or suggestions you could provide would be greatly appreciated. Thank you in advance.

If it is looking in the bin/ you will want to set the Copy Local property to True by right clicking on the reference and changing the value. This way, if you build in debug or release mode, the DLL will get copied to the appropriate bin/ location.

However, since this is in the GAC, you shouldn’t need to do this. I’d first uninstall the assembly from the GAC, and re-install it. Remove any project references and add it back where necessary (make sure Visual Studio is closed when you uninstall from the GAC and re-install to the GAC).

Thank you for the timely response. So, I tried to uninstall the System.Data.OracleClient assembly, but I receive the message that I can not remove becaues it is used by the .Net framework.

Did you perform an iisreset prior to attempting to removing the assembly? I find that occasionally there is a worker process still holding the assembly when I try and remove it.

Another option would be to try performing a repair on the .NET assembly or the OracleClient installation.

I performed an iisreset before trying to remove the assembly and recieved the same message stating it is required by .net. How do I go about repairing the Oracle Client installation or .Net assembly. Thanks for the help.

Add/Remove Programs or Programs and Features (for Windows Vista and after), then find the application, and right-click and choose repair.

I repaired .net 2.0 framework sp2. No change in error. System.Data.OracleClient didnt show up in Programs and features. Thanks for your help

After importing to VS 2012, what is the target framework for each project? You can find out by right clicking on the project and choosing properties (should be in the Application section).

.Net Framework 2.0 is the target framework for each project.

Boy I’m stumped. I’ve gone through my list of things. I’ve heard of some issues with VS 2012 and the installation of .NET 4.5 causing problems, but not specifically over the OracleClient. I also don’t know of any resolutions at this point either…

Thanks for all your help. I’ll let you know if I find a solution. :slight_smile:

The key phrase in that error message is “or one of it’s dependencies”; I’d turn on fusion logging and see what is happening under the surface – sounds like a strange 2nd level dependency thing that will make a lot of sense once you figure out.

Thanks, so I turned on fusion and I get this additional information about the error.

Assembly Load Trace: The following information can be helpful to determine why the assembly ‘System.Data.OracleClient, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089’ could not be loaded.

=== Pre-bind state information ===
LOG: User = CORP\\addison.sims
LOG: DisplayName = System.Data.OracleClient, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
LOG: Appbase = file:///C:/Users/addison.sims/dev/CorpServices/Sites/CorpServices/trunk/webroot/CorpServices/
LOG: Initial PrivatePath = C:\\Users\\addison.sims\\dev\\CorpServices\\Sites\\CorpServices\	runk\\webroot\\CorpServices\\bin
Calling assembly : (Unknown).

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\\Users\\addison.sims\\dev\\CorpServices\\Sites\\CorpServices\	runk\\webroot\\CorpServices\\web.config
LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config.
LOG: Post-policy reference: System.Data.OracleClient, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
ERR: An assembly with different processor architecture is already loaded.

Id try forcing the site to compile to x86 or x64 rather than anycpu and see what happens.

Try to compile to x64 resulted in this error:

Could not load file or assembly ‘CorpServices, Version=1.0.4780.29715, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Compiling to x86 resulted in the same Oracle Client error. Thanks for the suggestion.