0

I just can't understand why I can't use an old library in a .net Core app targeting Windows and the full .net framework (I don't care about multi-platform).

Just trying to understand the limits here. I don't want to hit a wall after investing too much into it.

Steps followed:

  1. Create a new .Net core web Application
  2. Added PetaPoco from NuGet (just an example)
  3. Can't use the library

enter image description here

enter image description here

Eduardo Molteni
  • 38,786
  • 23
  • 141
  • 206
  • http://stackoverflow.com/q/35343435/5311735. For whatever reason, PetaPoco nuget package does not copy files to your project (this package contains source code .cs file, not compiled dll). But even if it did copy that file - it won't work anyway, see that answer. – Evk Mar 07 '17 at 21:02
  • @Evk: It's not about this particular reference. I just want to understand why I can't use any arbitrary Windows DLL. (I don't care about multi-platform) – Eduardo Molteni Mar 07 '17 at 21:34
  • Your question doesn't even show you using .NET Core. Looks like you're using ASP.NET Core on the full .NET Framework. – mason Mar 07 '17 at 21:49
  • @mason: Yes. Thats the point of the question – Eduardo Molteni Mar 07 '17 at 21:57
  • Your title says . NET Core but your question shows full .NET Framework – mason Mar 07 '17 at 22:02
  • @mason The wizard always shows the full framework version even for core and native projects like C++ without `/cli`, it just ignores that drop-down for templates that don't use it. – Scott Chamberlain Mar 08 '17 at 13:26
  • @Scott yes, but look at what he drew the red box around. – mason Mar 08 '17 at 13:32

1 Answers1

2

From a comment from you on a deleted answer to this question

It's not about this particular reference. I just want to understand why I can't use an arbitrary Windows DLL. (I don't care about multi-platform) – Eduardo Molteni

It appears you are not too concerned why this specific project is not working (the deleted answer you commented on covered that quite well and if it was not deleted I would have up-voted it) but why in general you can't use a .NET Framework DLL in a .NET Core project.

Here is a diagram showing the layout of the ".NET ecosystem"

enter image description here

Things built for .NET Framework can't use DLLs built specifically for .NET Core, and things built for .NET Core can't use DLLs built specifically for .NET Framework because they are two "siblings" in the hierarchy.

Both .NET Framework and .NET Core can use .NET Standard libraries in their projects because .NET Standard is the "parent" of both the framework and core. Many newer NuGet packages now release versions that target .NET Standard so the library can be used with both versions. See the below chart to see what version of the .NET Standard library is compatible with various platforms. netstandard libraries are forward compatible so something that is compatible with 1.5 (like .NET 4.6.2) is also compatible with versions 1.0-1.4

enter image description here

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • But, the .Net Standard Library it's a not a library, the library it's still the .Net Framework (In this case). The question is: Do I need to wait for the world to move (recompile? repackage?) to .Net Standard before being able to use ASP.Net Core? – Eduardo Molteni Mar 08 '17 at 15:37
  • If there is a specific tool you rely on that has not been recompiled, then yes. – Scott Chamberlain Mar 08 '17 at 15:45
  • Why? The underlying system it's still Windows (Thanks to you and sorry to continue bothering, just can't get my head around the issue) – Eduardo Molteni Mar 08 '17 at 15:49
  • Because it does not have to be windows. If you are making a .NET Core app that app can be ran on any OS that supports .NET Core. For your specific case of why PetaPoco was not working, Elemental Pete had the correct answer for that (and I hope he undeletes his answer) – Scott Chamberlain Mar 08 '17 at 15:52
  • I understand that, if I was targeting .Net core, but I'm trying to do a ASP.NET Core app on the full .NET Framework (as shown in the question first image) – Eduardo Molteni Mar 08 '17 at 15:56
  • See [this github issue](https://github.com/NuGet/Home/issues/2262) if VS 2017 is doing the project.json style restore (which I think it is) you can't copy content files anymore like PetaPoco wants to do. That is why the PetaPoco library specifically does not work. Any other .NET project with just DLLs would have worked. – Scott Chamberlain Mar 08 '17 at 16:25