- 3,715,998 Users
- 2,242,925 Discussions
- 7,845,726 Comments
Forum Stats
Discussions
Categories
- 17 Data
- 362.2K Big Data Appliance
- 7 Data Science
- 1.6K Databases
- 476 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 5 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 417 SQLcl
- 42 SQL Developer Data Modeler
- 184.9K SQL & PL/SQL
- 21K SQL Developer
- 1.9K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 9 DevOps
- 3K QA/Testing
- 256 Java
- 6 Java Learning Subscription
- 10 Database Connectivity
- 67 Java Community Process
- 1 Java 25
- 9 Java APIs
- 141.1K Java Development Tools
- 6 Java EE (Java Enterprise Edition)
- 153K Java Essentials
- 135 Java 8 Questions
- 86.2K Java Programming
- 270 Java Lambda MOOC
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 10 Java SE
- 13.8K Java Security
- 3 Java User Groups
- 22 JavaScript - Nashorn
- 18 Programs
- 125 LiveLabs
- 30 Workshops
- 9 Software
- 3 Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 3 Deutsche Oracle Community
- 11 Español
- 1.9K Japanese
- 2 Portuguese
Can't connect to oracle in .net core web api

I have the following code:
using(OracleConnection conn = new OracleConnection(connectionstring))
{
var test = connection.Query<dynamic>("SELECT * FROM TABLE1")
}
When I run that, I get the following exception:
System.TypeLoadException: 'Could not load type 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.'
Why do I get this error? I have the latest beta installed.
Answers
-
Check this link
https://stackoverflow.com/questions/49159199/connect-to-oracle-database-in-dotnet-mvc-application
Maybe you have referenced wrong dll.
-
Hi,
I have already checked that. I have installed the dll from nuget.
-
Are you attempting to use Windows impersonation or any other Windows-specific (i.e. not supported in .NET Core) authentication method?
If not, can you generate a trace file and post it or email it to dotnet_us(at)oracle.com?
You can see how to set the trace setting in the following ODP.NET Core code sample: https://github.com/oracle/dotnet-db-samples/blob/master/samples/dotnet-core/configuration-api/config-api.cs
-
Hey,
No, im not attemting to use Windows impersonation or any other authentication method.
When I follow the sample that you provided, I get the following error message:
Could not load type 'Oracle.ManagedDataAccess.Client.OracleConfiguration' from assembly 'Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342'.
-
"Version=4.122.1.0" is managed ODP.NET. It is not ODP.NET Core.
Make sure you are installing Oracle.ManagedDataAccess.Core from NuGet. That "Core" part is the key part that distinguishes between managed ODP.NET and ODP.NET Core. You can only see the assembly if you tick the "Prerelease" checkbox since it's a beta.
If you're trying to run ODP.NET Core in .NET FW, make sure you don't have any managed ODP.NET versions in the GAC. Your app may be trying to use the GAC assemblies.
-
But that is the dll that I download from https://www.oracle.com/technetwork/topics/dotnet/downloads/odpnetcorebeta-4077982.html
Maybe you guys must change to the correct dll in that download?
What do you mean with running ODP.NET Core in .NET FW? My project is using .NET Core 2.0
However, I installed It from nuget with the following command:
Install-Package Oracle.ManagedDataAccess.Core -Version 2.12.0-beta3
I still get same error.
-
Maybe you guys must change to the correct dll in that download?
The download at that link is ODP.NET Core. The file version is 2.0.12.0 and product version 2.0.12.0.20180725Beta.
What do you mean with running ODP.NET Core in .NET FW? My project is using .NET Core 2.0
Because ODP.NET Core supports .NET Standard, it's possible to use ODP.NET Core in .NET FW. If you are using .NET FW, then I can see cases in which managed ODP.NET would be loaded, such as the assembly loaded in the GAC and overriding the local assembly.
The fundamental problem is your application is trying to use managed ODP.NET, but your .NET Core can't, which leads to the error.
To definitively figure this out, find the loaded assembly's directory location on your machine. Examine the assembly to see if it's the ODP.NET Core assembly or the managed ODP.NET assembly. The easiest way is to see if the version begins with a 4 (managed ODP.NET) or 2 (ODP.NET Core).