Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

[C#] Oracle.DataAccess issue - Unhandled exception of type System.TypeInitializationException occure

3029781Oct 14 2015 — edited Oct 23 2015

I created this topic as I could not find the answer even though there are many similar threads.


Recently many users reported that the tool created in Visual Studio stopped working. This is a WPF application written in C# and its purpose is to pick up Excel spreadsheets and export them to Oracle database for further calculations.

The application crashes when it attempts to create a class OracleBulkCopy which is a member of Oracle.DataAccess library (it is added to the project as Reference). The project was distributed among users as installation package and the idea was that they do not need to install anything else.


Currently I am investigating this issue on 3 machines:

  • 1 - my regular laptop
  • 2 - virtual machine set up on my laptop
  • 3 - old laptop delivered by my colleague

The application works well only on machine no 3 which has reinstalled Windows 7 64-bit and Oracle Client 11g (Oracle.DataAccess version 2.112.2.0). The other two also run on Windows 7 64-bit, we also tested the application using newer Oracle libraries with no positive effect. Machine number 1 is a bit messy as I removed or reinstalled many versions of DataAccess and in GAC they are all listed. I tried to setup machine no 2 (virtual machine, also fresh Windows 7 64bit) the same way as machine no 3 but the application still crashes so it brought me to conclusion that Oracle Client installation is not required but the problem is caused by something else.

Here is the error message and my findings after browsing some forums.

<photo1>

  1. I found some information about InnerException which I caught with try...catch. The description is as below:

Inner Exception

Step into: Stepping over property 'System.Exception.get_InnerException'. To step into properties, go to Tools->Options->Debugging and uncheck 'Step over properties and operators (Managed only)'. Step into: Stepping over property 'System.Exception.get_InnerException'. To step into properties, go to Tools->Options->Debugging and uncheck 'Step over properties and operators (Managed only)'. Step into: Stepping over property 'System.TypeLoadException.get_Message'. To step into properties, go to Tools->Options->Debugging and uncheck 'Step over properties and operators (Managed only)'. Step into: Stepping over property 'System.Console.get_Out'. To step into properties, go to Tools->Options->Debugging and uncheck 'Step over properties and operators (Managed only)'. at Oracle.DataAccess.Client.OpsInit.CheckVersionCompatibility(String version) at Oracle.DataAccess.Client.OracleInit.Initialize() at Oracle.DataAccess.Client.OracleConnection..cctor()Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The library OraOps11w (different version in fact) is available in the folder where Oracle Client was installed. I checked PATH system variables for each machine and they clearly point the right paths.


  1. GAC looks different in 3 cases. Laptop 1 shows total mess – as I mentioned earlier result of numerous re-installations. Laptop 3 (the old one which works fine) shows just 1 entry for Oracle.DataAcces and 2 Policy records. Laptop no 2 also shows the same libraries as laptop 3 but it does not work. I wanted to edit GAC lists but unfortunately due to lack of admin rights I am not able to do that either manually or with Gacutil.exe. If this may fix the problem the only option is to install the package with correct libraries.
  2. I also found a tutorial which suggests unloading the project and editing csproj. I corrected some values but this also did not bring the expected result.
  3. One discussion mentioned that faulty class may have static constructors but OracleBulkCopy does not have any static elements.


OracleBulkCopy class

     5. Recently I performed some tests on virtual machine and I noticed that when I launch the application as solution it works even without Oracle Client. When I convert the solution to install package and install on virtual machine it... works. Then when I distribute the installer and install the app on different machine the software is not working.


I am running out of ideas how this can be fixed. Have someone of you faced similar issue and managed overcome the problem?


Thanks for your help in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 20 2015
Added on Oct 14 2015
1 comment
2,600 views