0

I have a .NET Framework 4.7.2 console application, a .NET standard 2.0 business layer and a .NET standard 2.0 data access layer.

When I am trying to access data access layer from console application through the business layer, I am getting errors that say dependency not found. These dependencies are added to the data access layer and these are not related to console application like Dapper, OracleManagedDataAcess etc. If I added these libraries to the console application, it works. But I don't understand why do I have to add data access related libraries to the console application.

By the way if I switch the console application to .NET Core, it works as expected. But my console application has to be .NET framework. Any ideas?

Pac0
  • 16,761
  • 4
  • 49
  • 67
Umut Derbentoğlu
  • 1,066
  • 5
  • 17
  • 37
  • What sort of project file are you using for the console app? If you use an "SDK style" project file, but with a target framework of net472, I'd expect it to work. (The easiest way to do that is probably to make the console app .NET Core, then just edit the framework to net472 in the file directly.) – Jon Skeet May 31 '20 at 16:51
  • @JonSkeet it is not an sdk style project. – Umut Derbentoğlu May 31 '20 at 16:56
  • Right. So I suggest you *make* it an SDK-style project. – Jon Skeet May 31 '20 at 17:57

1 Answers1

0

I have found the answer in another post:

Copy all dependencies from .Net Standard libraries to .Net Framework Console application

Adding below line in the first "PropertyGroup" tag of the .net framework console application's ".csproj" file solved my problem.

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
Umut Derbentoğlu
  • 1,066
  • 5
  • 17
  • 37