Dnyandeo Narkhede
Dnyandeo Narkhede

Reputation: 41

Getting 'could not load file or assembly' error in .NET Core 2.0

I am getting the below error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'

What I did:

  1. Created new project in .NET Core 2.0.
  2. Added project reference of class library built out in .Net framework 4.6.1.
  3. Access function from class library which is using System.Data.OracleClient for database connection.
  4. But it's failing while invoking function with above error.

How do we support accessing old .NET libraries built out earlier with lot of internal references in .NET Core project?

Upvotes: 1

Views: 2718

Answers (1)

Guillaume S.
Guillaume S.

Reputation: 1545

Unfortunately, you cannot.

Your project built with .NET Core must have only libraries built for .NET Core. You can't use the one built for .NET Framework.

Here is a quote from the book ASP.NET Core in Action when deciding to develop with .NET Core rather than .NET Framework:

The largest obstacle you’re likely to come across is a third-party library holding you back, either because they only support older ASP.NET features, or they haven’t been converted to work with .NET Core yet.

Upvotes: 1

Related Questions