ODP.NET Web Application Fails While Configure Medium/High Trust Levels in IIS (Doc ID 1967542.1)

Last updated on FEBRUARY 12, 2015

Applies to:

Oracle Data Provider for .NET - Version 11.2.0.4 and later
Microsoft Windows x64 (64-bit) - Version: 2008 R2

Goal

Oracle Client : 11.2.0.4 (With Custom Installation)

Web server using ODP.NET to connect the Oracle Database . Application works fine while running IIS .NET trust level  equals to Low/Minimal . But when we change .NET trust level equals Medium/High it fails with below errors.

Application ID:
Process ID: 4852
Exception: System.TypeInitializationException
Message: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.
StackTrace: at Oracle.DataAccess.Client.OracleConnection.Dispose(Boolean disposing)
at System.ComponentModel.Component.Finalize()
InnerException: System.Security.SecurityException
Message: System.Security.Permissions.SecurityPermission
StackTrace: at Oracle.DataAccess.Client.OracleConnection..cctor()

There are 2 ways to Change Trust Levels

  1. Changing your trust level through IIS Manager.
  2. Using  web.config file

Add the following line between the <system.web> and </system.web> elements:

<trust level=" Medium” /> (replace “Medium “with your preferred trust level).

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms