.NET Core Library reference to .Net core Web project - asp.net-core

Getting following error when i try to add reference of .net core library reference in my web app.
Microsoft Visual Studio
The following projects are not supported as references :
DiscoverLib has target frameworks that are incompatible with targets in current project DiscoverWeb.
DiscoverWeb: .NETFramework,Version=v4.5.2
DiscoverLib: .NETStandard,Version=v1.6

Yes, that's expected/normal. .NETStandard 1.6 requires .NET Framework 4.6.3 (aka vNext) which is an unreleased version of the .NET Framework.
See this matrix for information. If you want to target .NET Framework 4.5.1 your class library must be ".NET Standard 1.2" or lower. This reduce the number of API you can use, so you always need to balance between minimum version supported and newest API.

Related

Is .NET Core 3.1 backward compatible?

I want to know if .NET Core 3.1 is backward compatible with .NET Core 2.1. I am getting below error while adding a nuget package(say package X) targeting .netcoreapp2.1 to my .netcoreapp3.1 project:
NU1202: Package is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package supports: netcore21 (.NETCore,Version=v2.1)
Note that the TFM netcore21 is not .NET Core 2.1.
Because the TFM netcorexx has been taken by some former deprecated platform that used to be called ".NET Core", which is not the well known .NET Core at all.
The proper TFM for .NET Core is netcoreappx.x (to be distinguished from the deprecated platform).
Thus this is irrelative to backward compatibility problem. And the nuget package that you are trying to add does not ever target any version of .NET Core.

.NET Core is not listed

I wanted to create a new ASP.NET Core app targeting the new .NET Core 1.0.
First, in Visual Studio 2015 Update 3, I don't see .NET Core listed
And this is what I'm seeing in project.json file. Looks like I'm targeing dotnet5.6
Is it safe to assume this is all correct?
And if this is correct, could it possibly be more confusing?
The pulldown has no meaning for .NET Core projects as it doesn't use it. Only what's in project.json matters for .NET Core / .xproj projects.
netcoreapp1.0 target framework moniker (short TFM) is .NET Core project for executables (ASP.NET Web Application or .NET Core Console Application). netstandard1.x (see this matrix for api surface of netstandard TFM) is for class libraries.
The import section just tells nuget to also restore packages which target dotnet5.6 (old TFM for .NET Core Library, which is now replaced with netstandard1.x) and portable-net45-win8, which are also compatible with .NET Core. These allow you to install packages which are compatible but are not yet repackaged for netstandard1.x.

Does dnx46 require at least .NET Framework 4.5.1?

In a new WebAPI project (trying ASP.NET Core 1.0) we have a requirement to query a legacy database "Pervasive SQL" using the ADO.NET Provider they provide. However they don't have a EF6 provider so we are stuck using EF5.
Skipping Entity Framework and using the ADO.NET PSqlConnection directly requires "System.Data 2.0.0.0". That makes me think the provider is compiled on .NET Framework 2.0 (or 3.5).
project.json
"frameworks": {
"net451": { },
"dnx46": {
"dependencies": {
"EntityFramework": "5.0.0",
"Pervasive.Data.SQLClient.Entity": "1.0.0-*",
"Pervasive.Data.SqlClient": "1.0.0-*",
"Pervasive.Data.Common": "1.0.0-*"
}
}
}
Running "dnu build" results into the following exception
xx\..\Controllers\ValuesController.cs(22,18): DNX,Version=v4.6 error CS0012: The type 'DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Build failed.
0 Warning(s)
2 Error(s)
The real question: Does dnx46 require at least .NET Framework 4.5.1 ?
Or is it somehow possible to referencing .NET Framework 3.5 (or 2.0) from ASP.NET Core 1.0?
The version of the moniker tells you already: It requires .NET Framework 4.6.
For 4.5.1 you need the dnx451 moniker.
But the essence is, 4.5 is minimum framework to use the new ASP.NET Core 1.0 (ASP.NET 5). You can see the matrix and how the moniker work on the ".Net Platform Standard" page on github.
Observations
If a library targets .NET Platform Standard version 1.3, it can only run on .NET Framework 4.6 or later, Universal Windows Platform 10 (UWP), DNX Core 5.0 and Mono/Xamarin platforms.
If a library targets .NET Platform Standard version 1.3, it can consume libraries from all previous .NET Platform Standard versions (1.2, 1.1, 1.0).
The earliest .NET Framework to support a .NET Platform Standard version is .NET Framework 4.5. This is because the new portable API surface area (aka System.Runtime based surface area) that is used as the foundation for the .NET Platform Standard only became available in that version of .NET Framework. Targeting .NET Framework <= 4.0 requires multi-targeting.
Each .NET Platform Standard version enables more API surface, which means it's available on fewer platforms. As the platforms update, their newer versions jump up into newer .NET Platform Standard versions.
Platforms which have stopped updating -- like Silverlight on Windows Phone -- will only ever be available in the earliest .NET Platform Standard versions.
Note
Please note that the moniker described there are for the current nightly builds. There are slight differences to the current RC1 release, i.e. it's dnx and dnxcore for dnx applications (ASP.NET, Console, unit-test projects) and net and dotnet for "Class Library (Package)". In RC2 current builds and RC it will be net and netstandard (also see this answer).

Portable F# library references .NET 4.5 (but not 4.0)

I'm trying to create portable F# library but it needs to target .NET 4.0 (company policy is that all portable libraries need to be compatible with Windows XP).
When I create (Visual Studio 2013) new project there is an option "Portable Library (Legacy)" with description saying "A project for creating an F# library (.dll) that can run on .NET Framework 4.0 and higher, Windows Store and Silverlight 5".
The problem is, when the project is actually created. When I go to project's properties "Target Framework" is set to ".NET Portable Subset (.NET Framework 4.5, Silverlight 5, Windows 8)".
I tried changing F# runtime version from 3.1 to 3.0 but it does not change anything. "3.0" and "3.1" are the only options. What happened to "2.0"?
Am I missing something?
EDIT: It seems like Grzegorz is right. I've created this F# PCL which is saying ".NET 4.5" and referenced it from .NET 4.0 C# application. No problems were reported.
Then, to be sure, I also referenced it from 3.5 application and... no problems were reported during compilation either, but it was crashing on runtime. So to be sure, I ran the "potentially 4.0" application on XP and it worked, which may be interpreted as: "Yes, F# PCL does not depend on 4.5 even it it says so".
Make it an answer so I can tick it.
The template file for "Portable Library (Legacy)" has TargetFrameworkVersion hardcoded as v4.0. If You'll create a project with this template it'll in fact target 4.0 version.
Probably, there's a bug in UI that keeps displaying target framework as 4.5 while in reality it uses previous one.
To be strict, the issue is related to legacy Portable Library. The non-legacy version seems to work correctly in forcing framework to be in 4.5 version.
update:
I submitted an issue about this to Visual F# Tools team:
https://visualfsharp.codeplex.com/workitem/95

ASP.NET MVC 4.0 RC and Newsoft.Json

I just installed the ASP.NET MVC 4.0 RC build on top of a Visual Studio 2010 SP1. My project that used to compile and work with the beta version of ASP.NET MVC 4.0, raises an error when I access the site saying that the Newtonsoft.Json assembly version 4.5 can not be found.
As I did not use this third party library in my current project, I configured Fusion Log to try to isolate the assembly that was relying on Newtonsoft.Json assembly.
And the guilty assembly is System.Net.Http.Formatting.dll which references Newtonsoft.Json version 4.5.
The beta build referenced System.Json.dll and not the Newtonsoft assembly.
I can hardly believe that Microsoft is starting to rely on external assemblies even if they publish more and more code in open source.
Does anyone have an explanation of what happened?
They are actually relying in third-party software (just like they ship MVC with JQuery and knockout.js). Scott Guthrie announced that MVC 4 will be shipped with JSON.NET (Newtonsoft). See below:
Json.NET: We plan to use the community developed Json.NET
serialization stack in our default JSON formatter in ASP.NET Web API.
Json.NET provides the flexibility and performance required for a
modern web framework.
http://aspnet.codeplex.com/wikipage?title=ASP.NET%20MVC%204%20RoadMap
You can keep the System.Json.dll btw, I've got them both. If you have any problems with JSON.NET, just reinstall it :)